/  50
 
January 11, 2006Week 3 meet in N-340 Number systemsBase b – digits from 0 to b-1Place values _ _ _ _ . _ _ _ _ Conversion between basesBase b to 10 – use place values of bEx. 0101 1001 = 89 base 1012AF = 1*16^3 + 2*16^2 + 10*16^1 + 15*16^0 = 4783Decimal to other bases58 = 111010Start with highest power of base that is <= number to convert.58/32 = 1 with 26 left26/16 = 1 with 10 left10/8 = 1 with 2 left2/4 = 0 with 2 left2/2 = 1 with0 left0/1 = 0 “”Convert decimal to hex1389 = 56Duse highest power of 16 <= 13891389 / 256 = 5 with 109 left109 / 16 = 6 with 13 left13 / 1 = 13 = D 0 left56DHex0 1 2 3 4 5 6 7 8 9 A B C D E FIn assembly, if the left most bit is 1, you must put a 0 in front of hex number.0FFh = 25501011011 – 5BhBinary to octal – group by 3's
 
001 011 011 = 133From hex to binary – pad binary number with 0's.B5 = 10110101Fractional parts of numbersExample: .3765 = .60624DMultiply fractional part by the new base0.3765 * 16 = 6.024.024 * 16 = 0.3840.384 * 16 = 6.1440.144 * 16 = 2.304.304 * 16 = 4.864.864 * 16 = 13.824.824 * 16 = 13.184.184 * 16 = 2.944Answer needs to fit number of bits that you have.Convert decimal to binarymultiply by new base0.725 * 2 = 1.450.45 * 2 = 0.90 * 2 = 1.8.8*2 = 1.60.6 * 2 = 1.20.10111001100...Addition with binary010101+ 1110011001110If I only have this much space, we have overflowAddition with hex12A8+617C7424Subtraction
 
111001-0101011001007424-12A8617C2's complement0000 0101 (5)1111 1011 (-5)32 bit integer has a range from -2
31
to 2
31
– 1 (to represent 0)A – B => A + (-B)To convert a number to 2's complement1)write the complement of the #Example: 00100110 => 110110012) add 1 => 11011010Other way, start on right side, use same digits up to & including the first 1after the first 1, flip the rest of the bits00101010 => 110101100110 1101 =>10010011January 18, 2006 N-340 next week both days.Subtraction with 2's complements1)Convert quantity to be subtracted to 2's complement2)Add 2's complement to other numbe3)If a carry out occurs, we ignore it and use same number of bits as are in arguments.Decimal:17 – 8 = 900010001 – 00001000Convert 8 to 2's complement – 11111000add that to 17

Share & Embed

More from this user

Add a Comment

Characters: ...