150 likes | 331 Views
http://mathforum.org/dr.math/faq/faq.bases.html. Background Reading. Cosc 235 Computer Organization. Number Systems. Objectives. Identify number systems other than decimal Convert between decimal & binary Cite the advantage of the binary number system for machine operation
E N D
http://mathforum.org/dr.math/faq/faq.bases.html Background Reading
Cosc 235Computer Organization Number Systems
Objectives • Identify number systems other than decimal • Convert between decimal & binary • Cite the advantage of the binary number system for machine operation • Cite the advantages of octal and hexadecimal number systems • Convert between octal and binary • Convert between decimal and BCD
Objectives (con’t) • Convert between binary and hexadecimal • Convert between decimal and hexadecimal • Convert between octal and decimal
General number system • Usually we use X = 10 • Ai can take on values in the range [0, X-1] … Radix point
Binary number system • Many electronic devices have 2 stable states • Problems 110010101112 101000100102 162310 129810
Converting any base to decimal • For base B, the base-10 representation of the number is • E.g.: • 36910 = 3x102 + 6x101 + 9x100 = 300 + 60 + 9 = 36910 • 5618 = 5x82 + 6x81 + 1x80 = 320 +48 + 1 = 36910 • 17116 = 1x162 + 7x161 + 1x160 = 256 + 112 + 1 = 36910 • 1011100012=28+26+25+24+20=256+64+32+16+1=36910
Converting from decimal to binary • Successive divisions by 2 • E.g., 83 • 83 • 41 R 1 • 20 R 1 • 10 R 0 • 5 R 0 • 2 R 1 • 1 R 0 • 0 R 1 => 10100112
Fractional numbers • 0.01112 = 0x2-1 + 1x2-2 + 1x2-3 + 1x2-4 = 0.25 + 0.125 + 0.0625 = 0.437510
Converting decimal fractions to binary • Method for fractional part F: • Repeat until F = 0 or “enough” digits found: • If F >= 0.5: • Bit value = 1 • F = F - 0.5 Else • Bit value = 0 • F = 2 * F
Octal number system • Convenient for dealing with Binary numbers • Typically used on machines where the number of bits per word is a multiple of 3 • Group 3 binary digits together to get one octal digit • 0002 = 08 0012 = 18 • 0102 = 28 0112 = 38 • 1002 = 48 1012 = 58 • 1102 = 68 1112 = 78
Converting from decimal to octal • Successive divisions by 8 • E.g., 830 • 830 • 103 R 6 • 12 R 7 • 1 R 4 • 0 R 1 => 14768
Hexadecimal number system • Convenient for dealing with Binary numbers • Typically used on machines where the number of bits per word is a multiple of 4 • Group 4 binary digits together to get one hex digit 00002 = 016 00012 = 116 00102 = 216 00112 = 316 01002 = 416 01012 = 516 01102 = 616 01112 = 716 10002 = 816 10012 = 916 10102 = A16 10112 = B16 11002 = C16 11012 = D16 11102 = E16 11112 = F16
Converting from decimal to hex • Successive divisions by 16 • E.g., 830 • 830 • 51 R 14 = E • 3 R 3 • 0 R 3 => 33E16
Binary Coded Decimal (BCD) • Represent 0-9 in 4 binary digits • 00002 = 010 • 00012 = 110 • 00102 = 210 • 00112 = 310 • 01002 = 410 • 01012 = 510 • 01102 = 610 • 01112 = 710 • 10002 = 810 • 10012 = 910 • Not binary