Presentation is loading. Please wait.

Presentation is loading. Please wait.

Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,

Similar presentations


Presentation on theme: "Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,"— Presentation transcript:

1 Number Systems

2 Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better, Arabic Numerals: 7 + 5 = 12 = 1 x 10 + 2

3 Arabic Numerals 345 is really 3 x 100 + 4 x 10 + 5 x 1 3 x 10 2 + 4 x 10 1 + 5 x 10 0 3 is the most significant symbol (carries the most weight) 5 is the least significant symbol (carries the least weight) Digits (or symbols) allowed: 0-9 Base (or radix): 10

4 Base 10 is a special case of positional number system First used over 4000 years ago in Mesopotamia(Iraq) Base 60 (Sexagesimal) Digits: 0..59 (written differently) 5,45 60 = 5 x 60 + 45 x 1 = 345 10 Positional number systems a great advance in mathematics Why?

5 Try multiplication in (non-positional) Roman numerals(!): XXXIII (33 in decimal) XII (12 in decimal) --------- XXXIII CCCXXX ----------- CCCXXXXXXXXXIIIIII CCCLXXXXVI CCCXCVI = 396 The Mesopotamians wouldn’t have had this problem.

6 There are many ways to “represent” a number Representation does not affect computation result LIX + XXXIII = LXXXXII (Roman) 59 + 33 = 92 (Decimal) Representation affects difficulty of computing results Computers need a representation that works with fast electronic circuits

7 Binary : positional numbers work great with 2-state devices Digits (symbols) allowed: 0, 1 Binary Digits, or bits Base (radix): 2 1001 2 is really 1 x 2 3 + 0 x 2 2 + 0 X 2 1 + 1 X 2 0 9 10 11000 2 is really ? Computers usually multiply Arabic numerals by converting to binary, multiplying and converting back (much as us with Roman numerals)

8 Octal number system: Digits (symbols): 0 – 7 Base (radix): 8 345 8 is really 3 x 8 2 + 4 x 8 1 + 5 x 8 0 192 + 32 + 5 229 10 1001 8 is really ? In C, octal numbers are represented with a leading 0 (0345 or 01001).

9 Hexadecimal number system: Digits (symbols) allowed: 0 – 9, a – f Base (radix): 16 HexDecimal a10 b11 c12 d13 e14 f15

10 A3 16 is really: A x 16 1 + 3 x 16 0 160 + 3 163 10 3E8 16 is really: 3 x 16 2 + E x 16 1 + 8 x 16 0 3 x 256 + 14 x 16 + 8 x 1 768 + 224 + 8 1000 10 10C 16 is really: ? In C, hex numbers are represented with a leading 0x (0xa3 or 0x10c).

11 For any positional number system: Base (radix): b Digits (symbols): 0..b – 1 S n-1 S n-2 ….S 2 S 1 S 0 Use sum to transform any base to decimal Value = Σ (S i b i ) n-1 i=0

12 Decimal  Binary Divide decimal value by 2 until the value is 0 (see book) Know your powers of two and subtract … 256 128 64 32 16 8 4 2 1 Example: 42 What is the biggest power of two that fits? What is the remainder? What fits? What is the remainder? What fits? What is the binary representation?

13 Binary  Octal Group into 3’s starting at least significant symbol Add leading 0’s if needed (why not trailing?) Write 1 octal digit for each group Example: 100 010 111 (binary) 4 2 7 (octal) 10 101 110 (binary) 2 5 6 (octal) Octal  Binary Write down the 3-bit binary code for each octal digit

14 Binary  Hex Group into 4’s starting al least significant symbol Adding leading 0’s if needed Write 1 hex digit for each group Example: 1001 1110 0111 0000 9 e 7 0 0001 1111 1010 0011 1 f a 3 Hex  Binary Write down the 4 bit binary code for each hex digit Example: 3 9 c 8 0011 1001 1100 1000

15 Hex  Octal Do it in 2 steps, hex  binary  octal Decimal  Hex Do it in 2 steps, decimal  binary  hex Why use hex and octal?

16 Negative Integers Most humans precede number with “-” (e.g., -2000) Accountants, however, use parentheses: (2000) Sign-magnitude Example: -1000 in hex? 1000 10 = 3 x 16 2 + e x 16 1 + 8 x 16 0 -3E8 16

17 Mesopotamians used positional fractions Sqrt(2) = 1.24,51,10 60 = 1 x 60 0 + 24 x 60 -1 + 51 x 60 -2 + 10 x 60 -3 = 1.414222 Most accurate approximations until the Renaissance What is 3E.8F 16 ? How about 10.101 2 ?

18 f f... f f f. f f f n-1 n-2 2 1 0 -1 -2 -3 Binary point 2 -1 =.5 2 -2 =.25 2 -3 =.125 2 -4 =.0625

19 Converting decimal to binary fractions Consider left and right of the decimal point separately. The stuff to the left can be converted to binary as before. Use the following algorithm to convert the fraction: FractionFraction x 2Digit left of decimal point 0.81.61  most significant (f -1 ) 0.61.21 0.20.40 0.80 (it must repeat from here!!) Different bases have different repeating fractions. 0.8 10 = 0.110011001100… 2 = 0.1100 2 Numbers can repeat in one base and not in another.

20 What is 2.2 in: Binary Hex


Download ppt "Number Systems. Prehistory Unary, or marks: / /////// = 7 /////// + ////// = ///////////// Grouping lead to Roman Numerals: VII + V = VVII = XII Better,"

Similar presentations


Ads by Google