Download presentation
Presentation is loading. Please wait.
Published byAsher Dixon Modified over 9 years ago
1
Negative binary numbers 1 Computer Architectures M
2
2 Negative binary numbers Many different coding systems: 2’ complement is almost always used Given a binary positive number its 2’s complement (negative equivalent) can be obtained by substituting the 1s with 0s and viceversa (bit complement operation) and summing then 1. Same procedure for converting 2’s complement negative numbers into positive numbers The 2’s complement negative numbers have a “1” as most significant bit in a relative numbers context and those positive (including the zero which is a “particolar” number – is a «not» number) have a “0” as most significant bit. The elementary operations with 2’s complement numbers produce 2’s complement numbers (very simple for sums and subtractions, more complex for moltiplications and divisions – Booth algorithm) 0100101 => 1011010 + 1 = 1011011 +37 => -37 1011011 => 0100100 + 1 = 0100101 -37 => +37
3
Negative binary numbers 3 In case of a carry beyond the MSB the carry must be discarded (automatically implemented in the computers for physical reasons ) 1011011+ -37+ 1100+ -4+ 0010010= 18= 1101= -3= ------- --- ---- -- 1101101 => 0010010 + 1= 0010011 -19 11001 -7 1011011 + -37 + 1010010 = -46 = ------- --- 10101101 ERROR – OVERFLOW -83 |-83| > 63 By summing two negative numbers we have obtained a positive number !!! “Overflow” error in the computers The 2’s complement provide correct results within the definition range (in our case with 7 bit – 6 bit plus sign – the numbers from -64 10 that is 1000000 up to +63 10 that is 0111111). In general with n bit the range is -2 n-1 to +2 n-1 -1 (because of the zero..). Example 4 bit (3 bit + sign ) range from 1000 -> -8 to 0111 -> +7 Careful !!
4
4 The zero remains unchanged (0000 => 1111+1 => 0000 discarding the last bit) Non integer number arithmetic is extremely complex (floating point numers) With N bit numbers (that is N-1 data bit plus sign) the numbers range is 2 N-1 --- 2 N-1 -1. Ex. With 8 bit (7 + 1 bit) -> 2 N-1 = 2 7 = 128 10 -> -2 N-1 = -128 and 2 N-1 -1 = 127 Negative binary numbers
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.