Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<pre><code> if(expA==expB) { if(debug) { printf("We got into the if exponents are the same block \n"); printf("Exp a: %x, Exp b: %x \n",expA,expB); } // exponents are the same // Add Mantissa B to A mantA = ADD(mantB,mantA); if(debug) { printf("Addition of mantissa's %x\n",mantA); } // store into the return value the logical and of the mantissa with the existing exponent and sign // might want to do an OR() not an AND() returnValue = OR(signExpA,mantA); } // end if the eponents are the same </code></pre> <p>This is wrong.</p> <p>You're failing to account for the addition of the two implicit ones. When you're adding 2 + 3 you're adding 1.0 x 2^1 + 1.1 x 2^1 and you're ignoring everything before the decimal point... So you end up with 0.0 + 0.1 = 0.1 and just stick a 1 at the front. You need to add the two implicit ones as well.</p> <p>Try something like this:</p> <pre><code> if(expA==expB) { if(debug) { printf("We got into the if exponents are the same block \n"); printf("Exp a: %x, Exp b: %x \n",expA,expB); } // exponents are the same // Add Mantissa B to A mantA = OR(implicitOne,mantA); mantB = OR(implicitOne,mantB); mantA = ADD(mantB,mantA); // You need to normalize this now. But shifting to the right by 1 will suffice. mantA &gt;&gt;= 1; ++expA; // ... add the sign and you're done... if(debug) { printf("Addition of mantissa's %x\n",mantA); } // store into the return value the logical and of the mantissa with the existing exponent and sign // might want to do an OR() not an AND() returnValue = OR(signExpA,mantA); } // end if the eponents are the same </code></pre>
 

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