Computer Systems 1 Fundamentals of Computing Negative Binary
Computer Systems 1 ( ) Negative Binary How significant are your bits? Binary Addition Rules Sign your name across my CPU Negative Binary Sign and Magnitude Two’s Complement
Computer Systems 1 ( ) Significance of Bits In binary there are two key aspects to a binary number: MSB = Most Significant Bit LSB = Least Significant Bit The largest binary value is deemed the most important Sometimes known as “Big-Endian” format E.g.- MSB LSB
Computer Systems 1 ( ) Binary Addition Binary addition is a key aspect of working with binary and using negative binary numbers Binary addition rules: = 0 = 1 = 1 = 10 (0 carry 1)
Computer Systems 1 ( ) Binary Addition E.g (11) (26) (2) (52) = 1101 (13) = (78) Binary addition skills are useful when dealing with binary arithmetic / negative numbers / subtraction
Computer Systems 1 ( ) Negative Binary ‘Normal’ Binary numbers are not indicative of whether the number is positive of negative Unsigned number Methods of negative number representation in binary have been devised: Negative binary representation forms Sign and Magnitude Two’s Complement A number which indicates it’s polarity is called a ‘signed number’
Computer Systems 1 ( ) Sign and Magnitude The MSB is an indicator A sign bit The MSB is only a sign, it is NOT part of the actual number The remaining number is the magnitude Binary 0 = positive number Binary 1 = negative number Numbers are padded out as required
Computer Systems 1 ( ) Sign and Magnitude E.g- = decimal 0 = decimal 1 (note 0 is postitive) = decimal -1 (note 1 is negative) = decimal 10 = decimal -10 = decimal 83 = decimal -83
Computer Systems 1 ( ) Two’s Complement Binary Uses an implicit sign bit The sign bit indicates if the number is positive or negative Binary 0 = positive Binary 1 = negative If the sign bit is set to 1, then the place value of that bit becomes negative when calculating the value The remaining values must then add to the number until it reaches the desired value The sign bit contributes to the value of the number (the magnitude)
Computer Systems 1 ( ) Two’s Complement Binary E.g.- 0101 = decimal 1011 = decimal = decimal = decimal
Computer Systems 1 ( ) Two’s Complement Binary Converting binary to Two’s complement: Take the original binary number and invert it’s values E.g (13) Then add 1 to the final value E.g = (-13) Because =(-13)
Computer Systems 1 ( ) CS1 What you know now: Significant bits: MSB LSB Binary addition Signed and Unsigned bits Negative binary Sign and Magnitude Non-inclusion of significant bit Two’s complement Inclusion of significant bits Conversion methods