Sie sind auf Seite 1von 20

Mathematics for

General Computing
Department of Mathematics
&
Computer Science
Faculty of Natural Sciences
The Open University of Sri Lanka

6/25/16

DMCS

What is a Number
System?
A 'number system' is a set of numbers, (in the
broadest sense of the word), together with one or
more operations, such as addition or
multiplication Wikipedia
Ex: Natural numbers, Integers, Rational Numbers,
Complex numbers, Binary, Octal, Decimal, etc..

6/25/16

Sample footer

Decimal Number System


Contain 10 digits
0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Called as 10 base number system

3 2 7
10 x
Bigger

6/25/16

102
DMCS

101

100
3

Binary Number System


We use the decimal system in everyday life because
it seems more natural (we have ten fingers and ten
toes).
For the computer, the binary system is more
natural because of its electrical nature (On versus
Off).
Has only two digits
1, 0
6/25/16

4
DMCS

Octal Number System


Contain 8 digits
0, 1, 2, 3, 4, 5, 6, 7
Programs often display data in octal format
because it is relatively easy for humans to read
Easily be translated into binary format
By contrast, decimal format is the easiest format
for humans to read, but translating between
decimal and binary formats is relatively difficult.
6/25/16

5
DMCS

Hexadecimal Number
System
Contain 16 digits
0, 1, 2, 3, 4, 5, 6, 7,8, 9, A, B, C, D, E, F
Easier for humans to read hexadecimal numbers
than binary numbers
Hexadecimal numbers have either an 0x prefix or
an h suffix

6/25/16

6
DMCS

Conversion between Number


system
Decimal to binary
Decimal to Octal
Decimal to Hexadecimal
Binary to Decimal
Octal to Decimal
Hexadecimal to Decimal
Octal to Binary
Hexadecimal to Binary
6/25/16

7
DMCS

Decimal to Binary
E.g.: convert decimal number 65 to binary

2
2
2
2
2
2

65
32 - 1
16 - 0
8-0
4-0
2-0
1-0

Sample footer

6510 = 1000001b
8

Binary to Decimal
1

01

2 2 2 2 2 2 2
6

64 32

16 8

1
=
64
+

0
=
0
+

0
=
0
+

0
=
0
+

0
=
0
+

2
x

0
=
0
+

1
x

1
=
1 = 65

Decimal to Octal
E.g.: convert decimal number 65 to octal

8
8

65
8-1
1-0

Sample footer

6510 = 101oct

10

Octal to Decimal
1

8 8 8
2

64
x
1
=
64
+

8
x
0
=
0
+

1
x
1
=
1
= 65
+

Decimal to Hexadecimal
E.g.: convert decimal number 65 to octal

16

65
4-1
6510 = 41hex

Sample footer

12

Hexadecimal to Decimal
4

16 16
1

16
x
4
=
64
+

1
x
1
=
1 = 65

Octal to Binary
3

011
3456
6/25/16

100
oct

6
101 110

= 011100101110b
Sample footer

14

Hexadecimal to Binary

0011 1111

0100 1010

3F7Ahex = 0011111101001010b

6/25/16

Sample footer

15

Bits and Bytes


Computer can understand only On or Off value as
On 1 Off -0
Therefore binary number system is used in
computer system
5V (ON)

0V (OFF)

Sample footer

16

Cont
The word bit is a shortening of the words "Binary digIT
8 bits = 1 byte
10110011 10111000 11110011 we have 24 bits that is
equal to 3 bytes
Eight-bit can represent 256 values (28 values, 0255)

Sample footer

17

Cont
When you start talking about lots of bytes, you get into
prefixes like kilo, mega and giga, as in kilobyte,
megabyte and gigabyte

6/25/16

18

ASCII
ASCII - American Standard Code for Information
Interchange
American Standard Institute has introduced coding
system to number all characters and numbers by giving it
a label between 0 and 255.
Ex: A 65 , B 66

To store a character we need to calculate binary


equivalent of ASCII number and send it to computer
Ex: A -65 01000001

There are other number system as EBCDIC, Extended


Binary Coded Decimal Interchange Code adopted by
IBM
6/25/16
Sample footer
19

Cont
ASCII is fine for the most common English characters,
numbers and punctuation but is a bit limiting for the rest of
the world
Therefore Unicode standards are using
These days the Unicode standard defines values for over
100,000 characters