Sections


Main-Menu

header image

Two’s Complement


So far, we have studied the representation of negative numbers using ten’s complement. In a computer, we prefer using base two rather than base ten. Luckily, the exact method described in the previous section works just as well for base two. For an n-bit adder (n is usually 32 or 64), we can represent positive numbers with a leftmost digit of 0, which gives values between 0 and 2(n-1) - 1, and negative numbers with a leftmost digit of 1, which gives values between -2(n - 1) and -1.

The exact same rule for overflow and underflow detection works. If, when adding two positive numbers, we get a result that looks negative (i.e. with its leftmost bit 1), then we have an overflow. Similarly, if, when adding two negative numbers, we get a result that looks positive (i.e. with its leftmost bit 0), then we have an underflow.


Related Articles :



Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.


Warning: include() [function.include]: http:// wrapper is disabled in the server configuration by allow_url_include=0 in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6

Warning: include(http://www.koolkampus.com/commoncode.php) [function.include]: failed to open stream: no suitable wrapper could be found in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6

Warning: include() [function.include]: Failed opening 'http://www.koolkampus.com/commoncode.php' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/koolkamp/public_html/engineering-notes-1/wp-content/themes/ankur/footer.php on line 6