Title: Beyond base 10: Nondecimal based number system
1Beyond base 10 Non-decimal based number system
- What exactly is decimal?
- How do other number systems work (binary, octal
and hex) - How to convert to and from non-decimal number
systems
2What is decimal?
- Base 10 the commonly used number system
- 10 unique symbols are used to represent values
Number of digits is based onnumber of digits
Largest value representable by a single digit 9
3Binary
- Base two
- Employs two unique symbols (0 and 1)
- Largest decimal value that can be represented by
1 binary digit 1 - The only language that the computer understands
(machine language bits (binary digits)
0000 1001 0010 1111 1000 0000 1111 1010 0000 1111
0000 1111
4Table of binary values
5Problems with binary
- A computer language not a people language!
- e.g., 0000 1111 0000 1111 ? What is my computer
doing? - Easier number systems later used
- Octal
- Hexadecimal
6Octal
- Base eight
- Employs eight unique symbols (0 - 7)
- Largest decimal value that can be represented by
1 octal digit 7
7Table of octal values
8Hexadecimal (hex)
- Base 16
- Employs sixteen unique symbols (0 9 plus A, B,
C, D, E, F) - Largest decimal value that can be represented by
1 hex digit 15
9Table of hex values
10Arbitrary based number system
- Base N
- Employs N number of unique symbols
- Largest decimal value that can be represented by
1 digit in this base N - 1
11Converting between different number systems
- Binary to/from octal
- Binary to/from hexadecimal
- Octal to/from hexadecimal
- Decimal to any base
- Any base to decimal
12Binary to Octal
- 3 binary digits equals one octal digit (remember
238) - Form groups of three at the decimal
- For the integer portion start grouping at the
decimal and go left - For the fractional portion start grouping at the
decimal and go right - e.g. 101 1002 ???8
.
13Octal to binary
- Each octal digit forms three binary digits
- e.g. 12.58 ???2
.
14Binary to hexadecimal
- 4 binary digits equals one hexadecimal digit
(remember 248) - Form groups of four at the decimal
- For the integer portion start grouping at the
decimal and go left - For the fractional portion start grouping at the
decimal and go right - e.g., 1000.01002 ???16
.
15Hex to binary
- Each hex digit forms four binary digits
- e.g., A.316 ???2
.
16Octal to/from hexadecimal
- Convert to binary first!
- e.g., 258 to ???16 (octal to hex)
17Octal to/from hexadecimal
- e.g., 1516 to ???8 (hex to octal)
18Decimal to any base
- Split up the integer and the rational portions
- For the integer portion keep dividing by the
target base until the remainder is less than the
target base - For the rational portion keep multiplying by the
target base until either the resulting product
equals zero (or you have the desired number of
places of precision)
19Decimal to any base an example
.2
9 / 2 q 4 r 1
/ 2 q 2 r 0
/2 q 1 r 0
20Any base to decimal
- Multiply each digit by the base raised to some
exponent1 and sum the resulting products. - i.e. d7 d6 d5 d4. d3 d2 d1b
- Base b
3 2 1 0 -1 -2
-3
Position of digits
Number to be converted
Value in decimal (d7b3) (d6b2) (d5b1)
(d4b0) (d3b-1) (d2b-2) (d1b-3)
1 The value of this exponent will be determined
by the position of the digit.
21Any base to decimal an example
1 2.
Value in decimal (181) (280) (18)
(21) 8 2 1010
22Summary (important points)
- How numbers are representing using different
bases - How to convert a number from one base to another
- Binary to/from octal
- Binary to/from hexadecimal
- Octal to/from hexadecimal
- Any base to/from decimal
- Decimal to/from any base