Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Regarding the "math" behind it: It's just the same as in the decimal system:</p> <p>When adding two single digit numbers, two cases have to be considered. Either the sum of the two is a new single digit number (5+4 = 9), or an 'overflow' occurs and another digit is required (5+6 = 11). Note that for any two numbers (in any base, be it 10, 2, 256 or whatever) of <code>n</code> digits length the sum of the two will <em>always</em> be lower than two times the lowest number of <code>n+1</code> digits length; let <code>i</code> and <code>j</code> be numbers (base 10) of, e.g., length 1, that is, both are between <code>0</code> and <code>9</code>, inclusive. As <code>10</code> is the lowest number of length <code>n+1 = 2</code>, their sum will always be lower than <code>2 x 10</code>.</p> <p>When adding two numbers, there may be no overflow or there may be an overflow of exactly 1. The carry bit stores this overflow from the last arithmetic operation; it's either 0 or 1.</p> <p>So, when adding your two numbers of 4x 8 bit each (which can be seen as 4 'digits' base 256), there will be no overflow to be considered for the first addition, hence only <code>ADD</code>; <code>ADD</code> can be regarded as an operation for <code>x = x + y + 0</code>. After the first addition however there may be an overflow which needs to be taken into account, which is done by using <code>ADDC</code>; <code>ADDC</code> represents the operation of <code>x = x + y + carry</code>, where <code>carry</code> can only be 0 or 1 as mentioned above. After all digits have been added, the last addition may have caused an overflow again which will be reflected in the carry bit afterwards and can be evaluated to possibly react to the overflow of the numberrange, like:</p> <pre><code>x = x + y; if ( carry == 1 ) { error "The sum is too big for the datatype of x"; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload