You are on page 1of 18

# Year 1

Human base

Computer base

NUMBER SYMBOL

Base

Lesson 1 - 1

CS113/0401/v1

Year 1

## POSITIONAL VALUES (1)

Decimal / Denary
Positional value Digit 100 2 10 5 1 8

## 258 =200+50+8 =2x100+5x10+8 x1 =2x10 +5x10 +8x10

2 1 0

Binary
Positional value Digit 32 1 16 1 8 0 4 1 2 0 1 1

## Decimal value of binary 110101

(1 x 32) + + + + + (1 x16) (0 x 8) (1 x 4) (0 x 2) (1 x 1)
CS113/0401/v1

32 16 0 4 0 + 1 53
Lesson 1 - 2

Year 1

## POSITIONAL VALUES (2)

Number System Base Digits Used Decimal 10 0 1 2 Binary 2 0 1 Octal 8 0 1 2 Hexadecimal 16 0 1 2

3
4 5 6 7 8 9

3
4 5 6 7

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

CS113/0401/v1

Lesson 1 - 3

Year 1

Octal
512 64 8 1

Positional value

Digit

+
+ +

(0x64)
(5x8 ) (6x1 ) +

0
40 6 1582

CS113/0401/v1

Lesson 1 - 4

Year 1

4096 256 16 1

Positional value

Digit

+ (Fx256)
+ (Ax16) + (6x1)

15x256
10x16

3840
160 + 6 12198

CS113/0401/v1

Lesson 1 - 5

Year 1

## FRACTIONAL QUANTITIES (1)

Decimal
Positional value 10 1 . 0.1 0.01 0.001

Digit

## Binary Fractions (Decimals)

Positional value Digit 4 1 2 0 1 1 . . 0.5 0.25 0.125 0 1 1

## Decimal value of binary 101.011

(1 x 4) + + + (0 x 2) (1 x 1) (0 x 0.5) 4.0 0.0 1.0 0.0

+
+

(1 x 0.25)
(1 x 0.125)
CS113/0401/v1

0.25
+ 0.125 5.375
Lesson 1 - 6

Year 1

## FRACTIONAL QUANTITIES (2)

Octal Fractions
Positional value Digit 8 3 1 1 . 0.125 0.015625 . 2 7

## Decimal value of octal 31.27 (3 x 8) 24.0

+ (1 x 1)
+ (2 x 0.125) + (7 x 0.015625) +

1.0
0.25 0.109375 25.359375

CS113/0401/v1

Lesson 1 - 7

Year 1

## FRACTIONAL QUANTITIES (3)

Positional value Digit . . 0.0625 C 0.00390625 F

## Decimal value of hexadecimal 0.CF

(C x 0.0625) 12 x 0.0625 0.75 +0.05859375 0.80859375

+ (F x 0.0390625)
15 x 0.0390625

CS113/0401/v1

Lesson 1 - 8

Year 1

## CONVERSION FROM DECIMAL TO OTHER BASES (1)

Divide by required base and note remainder Continue dividing quotients by required base until the answer is zero Write the remainder digits from right to left to give the answer 117 Decimal to Binary 2 ) 117 remainder 2 ) 58 2 ) 29 2 ) 14 2) 7 1 0 1 0 1

2)
2)

3
1 0

1
1

## 117 Decimal = 1 1 1 0 1 0 1 Binary

CS113/0401/v1 Lesson 1 - 9

Year 1

## CONVERSION FROM DECIMAL TO OTHER BASES (2)

236 Decimal to Octal 8 ) 236 remainder 8 ) 29 8) 8 4 5 3

## 236 Decimal = 3 5 4 Octal

437 Decimal to Hexadecimal 16 ) 473 remainder 16 ) 29 16 ) 1 9 13 1

437 Decimal= 1 D 9
CS113/0401/v1 Lesson 1 - 10

Year 1

## CONVERSION OF DECIMAL FRACTIONS (1)

Method

Multiply fraction part by base Remove integer part of result as first digit of answer Continue multiplying remaining fractional 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
Lesson 1 - 11

CS113/0401/v1

Year 1

## DECIMAL TO BINARY 0.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
CS113/0401/v1 Lesson 1 - 12

Year 1

DECIMAL TO OCTAL

## Use previous method outlined, but multiplying by 16 each time

Remember that integer part can be bigger than 10 giving A to F in the answer

CS113/0401/v1

Lesson 1 - 13

Year 1

## The three systems are closely related

Octal or hexadecimal are often used as shorthand for binary

Lesson 1 - 14

CS113/0401/v1

Year 1

## BINARY, OCTAL AND HEXADECIMAL (2)

Express each octal digit as three binary digits, or each hexadecimal digit as four binary digits, then write all the binary digit, as continuous string
OCTAL BINARY HEX 1 001 3 7 111 3 011 D 2 010 A

Add leading zeros (trailing zeroes to fractions) for clarity To convert from octal to hexadeximal or vice-versa go via binary
CS113/0401/v1 Lesson 1 - 15

Year 1

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 exceeds 8 7, by subtracting 8 and carrying 1 to the next column.

Example:

58 + 6 8 + 28 = 15 8 58 + 68 28 13 8 158
Lesson 1 - 16

## Decimal sum Modification Octal sum

CS113/0401/v1

Year 1

The sum of two hexadecimal digits, or the sum of two hexadecimal digits plus 1, can be obtained by : i. ii. Finding their decimal sum and Modifying the decimal, if it exceeds 15, by subtracting 16 and carrying 1 to the next column. A16 + 916 A + Decimal sum Modification Octal sum
CS113/0401/v1

Example :

9 19 16 13 16
Lesson 1 - 17

Year 1

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 what time 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 )
CS113/0401/v1 Lesson 1 - 18