DECIMAL BASE Based on power of 10 In the number 2,468 – from right to left -- the 8 represents the ones, the 6 represents the tens, the 4 represents the hundreds, the 2 represent the thousands. 2, 468 = 8*1 + 6*10 + 4* *1000 You can use ANY number for a base
Hexadecimal Numbers – Base 16 Decimal NumberHexadecimal Number A or a 11B or b 12C or c 13D or d 14E or e 15F or f
Hexadecimal Numbers cont. 0x283 – C++ uses 0X or 0x to indicate that the number is hexadecimal. ( i. e. if you have the number 283 how would you know if it is a hexadecimal or decimal ? )
Hexadecimal to decimal conversion 0X283 = 3 * 16^0 + 8*16^1 + 2*16^2 = = 3*1 + 8*16 + 2*256 = h = 637d ( another way to differentiate between hexadecimal and decimal but this notation is good in assembly language and for humans too )
Binary Numbers ( base 2 ) The computer’s number system Whether you write a n umber in decimal, hexadecimal, octal, or even other base, the computer stores it in binary The memory is commonly organized in units called bytes ( 1 byte = 8 bits )
Conversion Binary numbers to Decimal = 1*2^0 + 1 * 2^1 + 1 * 2^2 + 0*2^3 + 1*2^4 + 1*2^5 + 0*2^6 + 0*2^7 + 1*2^8 = 1*1 + 1 * * * * * * * * 256 = = 311
Easier Way to convert binary to base
Base Table Decimal DigitBinary DigitHexadecimal Digit A B C D E F
Conversion from Decimal to Binary and Hexadecimal LONG DIVISION….. Pay attention in class Or Google – there are excellent sites that you can learn how to do it: Here is one of them: onv.html#Dec2Bin1 onv.html#Dec2Bin1