Download - MELJUN CORTES Number Bases
-
7/29/2019 MELJUN CORTES Number Bases
1/18
Lesson 1 - 1
Year 1
CS113/0401/v1
LESSON 1
NUMBER BASES
Human base
10
Ten finger
DECIMAL
Computer base
2
Two-state devices
BINARY
NUMBER SYMBOL
Base
Number of symbols
Number of states
-
7/29/2019 MELJUN CORTES Number Bases
2/18
Lesson 1 - 2
Year 1
CS113/0401/v1
Decimal / Denary
258 =200+50+8=2x100+5x10+8 x1
=2x10 +5x10 +8x10
Binary
Decimal value of binary 110101
(1 x 32) 32
+ (1 x16) 16
+ (0 x 8) 0
+ (1 x 4) 4
+ (0 x 2) 0
+ (1 x 1) + 153
Positional valueDigit
1002
105
18
Positional valueDigit 321 161 80 41 1120
POSITIONAL VALUES (1)
2 1 0
-
7/29/2019 MELJUN CORTES Number Bases
3/18
Lesson 1 - 3
Year 1
CS113/0401/v1
POSITIONAL VALUES (2)
Base 10 2 8 16
Number
SystemDecimal Binary Octal Hexadecimal
DigitsUsed
0
1
2
3
4
5
6
7
8
9
0
1
0
1
2
3
4
5
6
7
0
1
2
3
4
5
6
7
8
9
0
A
B
C
D
EF
-
7/29/2019 MELJUN CORTES Number Bases
4/18
Lesson 1 - 4
Year 1
CS113/0401/v1
Octal
Decimal value of octal 3056
+ (3x512) 1536
+ (0x64) 0
+ (5x8 ) 40
+ (6x1 ) + 6
1582
Positional value
Digit
512
3
64
0
8
5
1
6
POSITIONAL VALUES (3)
-
7/29/2019 MELJUN CORTES Number Bases
5/18
Lesson 1 - 5
Year 1
CS113/0401/v1
Hexadecimal
Decimal Value of hexadecimal 2FA6
(2x4096) 8192
+ (Fx256) 15x256 3840
+ (Ax16) 10x16 160
+ (6x1) + 6
12198
Positional value
Digit
4096
2
256
F
16
A
1
6
POSITION VALUES (4)
-
7/29/2019 MELJUN CORTES Number Bases
6/18
Lesson 1 - 6
Year 1
CS113/0401/v1
Decimal
Binary Fractions (Decimals)
Decimal value of binary 101.011
(1 x 4) 4.0
+ (0 x 2) 0.0
+ (1 x 1) 1.0
+ (0 x 0.5) 0.0
+ (1 x 0.25) 0.25
+ (1 x 0.125) + 0.125
5.375
Positional value
Digit
10
3
1
6
.
.
0.1
5
0.001
8
0.01
2
Positional value
Digit
4
1
2
0
.
.
0.5
0
0.125
1
0.25
1
1
1
FRACTIONAL QUANTITIES
(1)
-
7/29/2019 MELJUN CORTES Number Bases
7/18
Lesson 1 - 7
Year 1
CS113/0401/v1
Octal Fractions
Decimal value of octal 31.27
(3 x 8) 24.0
+ (1 x 1) 1.0
+ (2 x 0.125) 0.25
+ (7 x 0.015625) + 0.109375
25.359375
Positional value
Digit
8
3
1
1
.
.
0.125
2
0.015625
7
FRACTIONAL QUANTITIES
(2)
-
7/29/2019 MELJUN CORTES Number Bases
8/18
Lesson 1 - 8
Year 1
CS113/0401/v1
Hexadecimal Fractions
Decimal value of hexadecimal 0.CF
(C x 0.0625)
12 x 0.0625 0.75
+ (F x 0.0390625)15 x 0.0390625 +0.05859375
0.80859375
Positional value
Digit
.
.
0.0625
C
0.00390625
F
FRACTIONAL QUANTITIES
(3)
-
7/29/2019 MELJUN CORTES Number Bases
9/18
Lesson 1 - 9
Year 1
CS113/0401/v1
Divide by required base and note
remainder
Continue dividing quotients by requiredbase until the answer is zero
Write the remainder digits from right to left
to give the answer
117 Decimal to Binary
2 ) 117 remainder 1
2 ) 58 0
2 ) 29 1
2 ) 14 0
2 ) 7 1
2 ) 3 1
2 ) 1 1
0
117 Decimal = 1 1 1 0 1 0 1
Binary
CONVERSION FROM
DECIMAL TO OTHER BASES(1)
-
7/29/2019 MELJUN CORTES Number Bases
10/18
Lesson 1 - 10
Year 1
CS113/0401/v1
236 Decimal to Octal
8 ) 236 remainder 48 ) 29 5
8 ) 8 3
236 Decimal = 3 5 4 Octal
437 Decimal to Hexadecimal
16 ) 473 remainder 9
16 ) 29 13
16 ) 1 1
437 Decimal= 1 D 9Hexadecimal
CONVERSION FROM
DECIMAL TO OTHER BASES(2)
-
7/29/2019 MELJUN CORTES Number Bases
11/18
Lesson 1 - 11
Year 1
CS113/0401/v1
CONVERSION OF DECIMAL
FRACTIONS (1)
Method Multiply fraction part by base
Remove integer part of result as
first digit of answer
Continue multiplying remainingfractional parts by the base and
extracting the resulting integers
as answer digits
Stop when answer contains
enough digits for accuracy
required, or when remaining
fraction is zero
If remaining fraction is zero, the
representation is exact
-
7/29/2019 MELJUN CORTES Number Bases
12/18
Lesson 1 - 12
Year 1
CS113/0401/v1
DECIMAL TO BINARY0.743 Decimal to Binary
.743 x 2
1 .486 x 2
0 .972 x 2
1 .944 x 2
1 .888 x 2
1 .776 x 2
1 .552 x 2
1 .104 x 2
0 .208
0.1 0 1 1 1 1 1 0 Binary
= 0.743
CONVERSION OF DECIMAL
FRACTIONS (2)
-
7/29/2019 MELJUN CORTES Number Bases
13/18
Lesson 1 - 13
Year 1
CS113/0401/v1
CONVERSION OF DECIMAL
FRACTIONS (3)
DECIMAL TO OCTAL Use previous method outlined,
but multiplying by 8 each time
DECIMAL TO HEXADECIMAL Use previous method outlined,
but multiplying by 16 each time
Remember that integer part canbe bigger than 10 giving A to F in
the answer
-
7/29/2019 MELJUN CORTES Number Bases
14/18
Lesson 1 - 14
Year 1
CS113/0401/v1
BINARY, OCTAL AND
HEXADECIMAL (1)
The three systems are closely
related
Octal or hexadecimal are often
used as shorthand for binary
Example : Store dumps
Group binary digits
in threes for octal
in fours for hexadecimal
-
7/29/2019 MELJUN CORTES Number Bases
15/18
Lesson 1 - 15
Year 1
CS113/0401/v1
Express each octal digit as threebinary digits, or each hexadecimal
digit as four binary digits, then write
all the binary digit, as continuous
string
OCTAL 1 7 3 2
BINARY 0 0 1 1 1 1 0 1 1 0 1 0
HEX 3 D A
Add leading zeros (trailing zeroes to
fractions) for clarity
To convert from octal to hexadeximal
or vice-versa go via binary
BINARY, OCTAL AND
HEXADECIMAL (2)
-
7/29/2019 MELJUN CORTES Number Bases
16/18
Lesson 1 - 16
Year 1
CS113/0401/v1
The sum of two octal numbers can be
deduced by the usual addition algorithm
to the repeated addition of two digits (
with possibly a carry of 1 ). The sum of two octal digits, or the sum
of two octal digits plus 1, can be
obtained by :
i. Finding their decimal sum and
ii. Modifying the decimal, if it exceeds7, by subtracting 8 and carrying 1 to
the next column.
Example: 5 + 6 + 2 = 15
5
+ 6
2
Decimal sum 13
Modification - 8
Octal sum 15
OCTAL ADDITION
8
8 8 8 8
8
8
8
8
-
7/29/2019 MELJUN CORTES Number Bases
17/18
Lesson 1 - 17
Year 1
CS113/0401/v1
The sum of two hexadecimal digits, or
the sum of two hexadecimal digits plus
1, can be obtained by :
i. Finding their decimal sum and
ii. Modifying the decimal, if it exceeds15, by subtracting 16 and carrying
1 to the next column.
Example : A + 9
A
+ 9
Decimal sum 19
Modification - 16
Octal sum 13
HEXADECIMAL ADDITION
1616
16
-
7/29/2019 MELJUN CORTES Number Bases
18/18
Lesson 1 - 18
Year 1
CS113/0401/v1
MODULAR ARTHMETIC
In our daily life, there are so many
counting / measuring systems around
us.
E.g. 100 cm is not the same as 100
inches, because measuring is different.
Example:
If Peter starts work at 8 0 clock in the
morning and work for 8 hours, at whattime will Peter finish work?
Solution:
Step 1. Add 8 hours to 8 o clock
= ( 8 + 8 = 16 )
Step 2. 16 Divide by 12
( because 12 hours )
= ( 16 mod 12 )
Step 3. The remainder is 4
= ( 16 mod 12 = 4 )