CS 231Intro & Base ConversionsCelal ZiftciAug 26, 2005Announcements Mallard is up. Try to log on and take the first quiz (due Monday, Aug 29) Course webpage is down Mallard link is posted on the newsgroup(https://mallard2.cites.uiuc.edu/CS231/) First homework assignment to be released sometime next weekTips for CS 231 Don’t hesitate to: Ask questions Interrupt when you don’t understand Be comfortable with binary and hex Learn device inputs & outputs Allows abstraction Easier to understand Show your workTips for CS 231 Efficiency is important! Neatness is important! Unreadable solutions are considered wrong Readable ones are neat, short (big favor for both you and the graders) Digits = powers of 10… 100, 10, 1,1/10,1/100,1/1000 ……102, 101,100,10-1,10-2,10-3 …Ex: (36.25)10= 3*10 + 6*1 + 2*1/10 + 5* 1/100 Bits = powers of 2…8, 4,2,1,1/2,1/4,1/8 ……23, 22, 21,20,2-1,2-2,2-3 …Ex: (100100.01)2= 1*32 + 1*4 + 1*1/4Digits vs. bitsBinary to decimal add powers that have a 1(101001)2= 32 + 8 + 1(0.1001)2= 1/2 + 1/16(10110.1011)2= ?16 + 4 + 2 + 1/2 + 1/8 + 1/16= 22.6875Decimal to binary Left of decimal point Repeatedly divide integer part by 2 until you get 0 Read remainders bottom to up22 = (?)22211 R 05R 12R 11R 00R 1Decimal to binary Left of decimal point Repeatedly divide integer part by 2 until you get 0 Read remainders bottom to up22 = (10110)22211 R 05R 12R 11R 00R 1Decimal to binary Right of decimal point Repeatedly multiply fractional part by 2 until you get 1 Read integer portion top to bottom0.8125 = (?)20.81251.62501.250.51.0Decimal to binary Right of decimal point Repeatedly multiply fractional part by 2 until you get 1 Read integer portion top to bottom0.8125 = (0.1101)20.81251.62501.250.51.0Decimal to binary What if there are both left and right of the decimal point? Do them separately and combine22.8125 = (?)2Decimal to binary What if there are both left and right of the decimal point? Do them separately and combine22.8125 = (?)22211 R 05R 12R 11R 00R 10.81251.62501.250.51.0Decimal to binary What if there are both left and right of the decimal point? Do them separately and combine22.8125 = (10110.1101)22211 R 05R 12R 11R 00R 10.81251.62501.250.51.0up downDecimal to binary Toy example3.25 = (?)231 R 10 R 10. 250.501.0Decimal to binary Toy example3.25 = (11.01)231 R 10 R 10. 250.501.0Hexadecimal base Hex digits = powers of 16…256, 16, 1,1/16,1/256 ……162, 161,160,16-1,16-2 … use digits 0-9, A-F A=10, B=11, C=12, D=13, E=14, F=15 often preceded by 0x book subscript notation (24.4)16Ex: (24.4)16= 2*16 + 4*1 + 4*1/16Hexadecimal base Hex (hexadecimal) Hex digit is a group of 4 bits Memorize this table!!dec. hex binary0 0 00001 1 00012 2 00103 3 00114 4 01005 5 01016 6 01107 7 01118 8 10009 9 100110 A 101011 B 101112 C 110013 D 110114 E 111015 F 1111 Hex (hexadecimal) Group from decimal point outward Pad with zeros to get groups of 4(1101101001010.101001)2(0001 1011 0100 1010 . 1010 0100)21 B 4 A . A 4(1101101001010.101001)2= (1B4A.A4)16Binary to Hex Octal digits = powers of 8…64, 8, 1,1/8,1/64 ……82, 81,80,8-1,8-2 … use digits 0-7 sometimes preceded by 0 book subscript notation (24.4)8Ex: (44.2)8= 4*8 + 4*1 + 2*1/8Octal base Octal Octal digits are groups of 3 bits Pad with zerosdec. octal binary0000011001220103301144100551016611077111Octal base Octal Group from decimal point outward Pad with zeros to get groups of 3(1101101001010.101001)2(001 101 101 001 010 . 101 001)21 5 5 1 2 . 5 1(1101101001010.101001)2= (15512.51)8Binary to Octal What about other conversions such as: Octal Æ Hex Decimal Æ Hex … Use other conversions you already know Octal Æ Binary Æ Hex Decimal Æ Binary Æ HexOther conversionsI. Decimal Æ BinaryBinary Æ DecimalII. Binary Æ HexBinary Æ OctalIII. Other conversions Use the conversions you already
View Full Document