Number Systems Ron Christensen CIS 121
Positional Notation “Positional Notation” Value of a digit depends on the position of the digit Positional Notation permits unique representation of Integers
Positional Notation Decimal numbers are “Base 10 positional notation” Base 10 means that the value of any position is a multiple of a power of 10 Binary numbers are “Base 2 Positional notation” Octal numbers are “Base 8 Positional notation” Hexadecimal numbers are “Base 16”
Positional Notation The value of digit n is baseN N0 = 1 no matter what N is In decimal notation the value of digit N is 10N “19” = 1x101 + 9x100
Base 10 Base 10 uses ten symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. This is called a decimal number system and is the one with which people are most familiar.
Why Binary? Build Transistor
Base 2 Base 2 has exactly two symbols: 0 and 1. This is called a binary system and all numbers must be formed using these two symbols.
Base 8 Base 8 uses eight symbols: 0, 1, 2, 3, 4, 5, 6, and 7. This is called an octal number system and is a convenient shorthand for base 2 numbers. One octal digit is the equivalent of three binary digits.
Base 16 Base 16 uses sixteen symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. This system is called hexadecimal and can also serve as a shorthand for the binary number system.
Converting Number Systems It is sometimes necessary or more convenient to convert numbers in one system to those in another.
Converting Base 2 (Binary) to Base 10 (Decimal) In binary notation the value of digit N is 2N “1011” = 1x24 + 0x23 + 1x21 + 1x20 = 8+0+2+1 = 11 What is the decimal value of 110110001? 1x28 + 1x27 + 1x25 + 1x24 + 1x20 = 256 + 128 + 32 + 16 + 1 = 433
Converting Base 2 to Base 8 To convert base 2 to base 8, combine the binary digits from the right in groups of three and convert. 111101001011 111 101 001 011 7 5 1 3
Converting Base 2 to Base 16 To convert base 2 to base 16, combine the binary digits from the right in groups of four and translate. 111101001011 1111 0100 1011 F 4 B
Converting Base 8 to Base 2 To convert base 8 to base 2, convert each octal digit into 3 binary digits. 7513 111 101 001 011 111101001011
Converting Base 8 to Base 16 To convert base 8 to base 16, first translate into base 2 then into base 16. 7513 111 101 001 011 1111 0100 1011 F 4 B
Converting Base 10 to Base 2 To convert base 10 to base 2, divide the number repeatedly by 2; use remainders as answer. On your own, try: 2363.
Practice What is the binary value of 120? First division is 120/2. Q=60, R=0 Second division is 60/2. Q=30, R=0 Third division is 30/2. Q=15, R=0, Fourth division is 15/2. Q=7, R=1 Fifth division is 7/ 2. Q=3, R=1 Sixth division is 3/2. Q=1, R=1 Seventh division = 1 / 2. Q=0, R=1 Quotient is zero, so we stop. 12010 = 11110002
Converting Base 10 to Base 8 To convert base 10 to base 8, divide the number repeatedly by 8; use remainders as answer. On your own, try: 2363.
Converting Base 10 to Base 16 To convert base 10 to base 16, divide the number repeatedly by 16; use remainders as answer. On your own, try: 2363.
Converting Base 16 to Base 2 To convert base 16 to base 2, translate each hexadecimal digit to 4 binary digits. On your own, try: 4BC.
Converting Base 16 to Base 8 To convert base 16 to base 8, translate to base 2 then to base 8. On your own, try: 4BC.
Converting Base 16 to Base 10 To convert base 16 to base 10, expand the number and translate base 16 digits to base 10. On your own, try: 4BC.
Practice The number “123DF” in decimal is 1x164 + 2x163 + 3x162 + 13x161 + 15x160 65536 + 8192 + 768 + 208 + 15 = 74719
Conversions are done with calculators Number Systems Binary is used by hardware Hex numbers are used in many places HTML color codes Decimal numbers appear in user interfaces Conversions are done with calculators
Binary Encoding – Data Binary numbers work well for positive integers Not all data is positive integer: Negative integers Real numbers, e.g. decimal points Characters