Number systems

22
Applied physics III Number systems by Benson Mbuya 1

Transcript of Number systems

Page 1: Number systems

Applied physics III

Number systems

by Benson Mbuya1

Page 2: Number systems

Decimal System

• Most people today use decimal representation to count. In the decimal system there are 10 digits: 

0, 1, 2, 3, 4, 5, 6, 7, 8, 9• These digits can represent any value, for

example:754.The value is formed by the sum of each digit, multiplied by the base (in this case it is 10 because there are 10 digits in decimal system) in power of digit position (counting from zero): 2

Page 3: Number systems

Decimal System

• Position of each digit is very important! for example if you place "7" to the end:547it will be another value:

3

Page 4: Number systems

Decimal System

4

Page 5: Number systems

The decimal system

• In the decimal number system, each digit 0 through 9 represents either itself, or else itself times some power of 10.

• The value of the digit depends on its position or place in the number.

• In the case of the number 35912, the digit 2 is in the units place, and has a value of simply 2.

• The digit 1 is in the 10s place; it takes the value of 1 x =10.

• The digit 9 is in the 100s place, having a value of 9 × = 900.

5

Page 6: Number systems

The decimal system

• The digit 5 is in the 1,000s place, and represents 5 10 3 5000.

• The digit 3 is in the 10,000s place, and• has a value of 3 104 30,000. • The total value is the sum of all these: 2 + 10+ 900 + 5,000 + 30,000 = 35,912.

6

Page 7: Number systems

The decimal system

• A decimal number can be represented in digital form.

• Any decimal number has a binary equivalent composed of digits that are all either 0 or 1

• four-digit number ‘‘1,234’’ was built out of four digits, any of which could have the 10 values ‘‘0’’, ‘‘1’’, ‘‘2’’, ‘‘3’’, ‘‘4’’, ‘‘5’’, ‘‘6’’, ‘‘7’’, ‘‘8’’ and ‘‘9’’.

• The number of different values for each digit is referred to as its ‘‘base’’ or‘‘radix’’.

• It is important to note that the first value is always zero and the last value is the base minus one.

7

Page 8: Number systems

The Binary system

• Computers use binary system, binary system uses 2 digits: 0, 1And thus the base is 2. 

• Each digit in a binary number is called a BIT,

• 4 bits form a NIBBLE, • 8 bits form a BYTE, • two bytes form a WORD,• two words form a DOUBLE WORD(rarely

used):

8

Page 9: Number systems

The Binary system

• There is a convention to add "b" in the end of a binary number, this way we can determine that 101b is a binary number with decimal value of 5. 

• The binary number 10100101b equals to decimal value of 165: 

9

Page 10: Number systems

The Binary system

10

Page 11: Number systems

Octal system (Base 8)

• the system is based on the number eight (as opposed to ten). Remember how in base-10 we had ten digits? Now, in base-8, we are limited to only eight digits: 0, 1, 2, 3, 4, 5, 6, and 7. There’s no such thing as 8 or 9.

• after we get to 7, we run out of different digits for any higher number. We need a way to represent eight of something. So we add another digit, change the 7 back to 0, and end up with 10. Our answer of 10 in base-8 now represents what we would normally think of as 8 in base-10.11

Page 12: Number systems

Octal system (Base 8)

• What’s the next number after 778? If you said 1008, you’re correct. We know from what we’ve learned so far that the first 7 in 778 represents groups of 8, and the second 7 represents induvidual items. If we add these all up, we have 7*8 + 7*1 = 63. So we have a total of 6310. So 778=6310. We all know 6410comes after 6310.

12

Page 13: Number systems

Converting From Base-8 to Base-10

13

Page 14: Number systems

Converting from Base-10 to Base-8

• Let's start with an example: 15010

14

Page 15: Number systems

Hexadecimal System

• Hexadecimal System uses 16 digits:

0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

And thus the base is 16. 

• Hexadecimal numbers are compact and easy to read.

• It is very easy to convert numbers from binary system to hexadecimal system and vice-versa, every nibble (4 bits) can be converted to a hexadecimal digit using this table: 

15

Page 16: Number systems

Hexadecimal System

16

Page 17: Number systems

Hexadecimal System• There is a convention to add "h" in the end of a

hexadecimal number, this way we can determine that 5Fh is a hexadecimal number with decimal value of 95.We also add "0" (zero) in the beginning of hexadecimal numbers that begin with a letter (A..F), for example 0E120h. 

The hexadecimal number 1234h is equal to decimal value of 4660:

17

Page 18: Number systems

Converting from Decimal System to Hexadecimal

• In order to convert from decimal system, to any other system, it is required to divide the decimal value by the base of the desired system,

• each time you should remember the result and keep the remainder, the divide process continues until the result is zero.

• The remainders are then used to represent a value in that system. 

18

Page 19: Number systems

Converting from Decimal System to Hexadecimal

• Let's convert the value of 39 (base 10) to Hexadecimal System (base 16): 

• As you see we got this hexadecimal number: 27h.All remainders were below 10 in the above example, so we do not use any letters.

19

Page 20: Number systems

Converting from Decimal System to Hexadecimal

• Here is another more complex example:let's convert decimal number 43868 to hexadecimal form:

The result is 0AB5Ch, we are using the above table to convert remainders over 9 to corresponding letters. 

20

Page 21: Number systems

Converting from Hexadecimal to Binary

• Using the same principle we can convert to binary form (using 2 as the divider), or convert to hexadecimal number, and then convert it to binary number using the above table:

• As you see we got this binary number: 1010101101011100b 21

Page 22: Number systems

references• Chapter 30, Teach yourself electronics, 3rd ed,

Stan Gibilisco.• Chapter 4, digital electronics demystified, Myke

Predko.• Chapter 18, Schaums outline: basic mathematics

with applications to science and technology, Kruglak, Moore.

• http://www.electronics.dit.ie/staff/tscarff/number_systems/number_systems.html

• http://active.tutsplus.com/tutorials/coding-concepts/number-systems-an-introduction-to-binary-hexadecimal-and-more/

• http://www.math.grin.edu/~rebelsky/Courses/152/97F/Readings/student-binary

• http://active.tutsplus.com/tutorials/coding-concepts/number-systems-an-introduction-to-binary-hexadecimal-and-more/

22

22