You are on page 1of 23

2023

DATA
REPRESENTATION
Anish
Pokharel
Content
01 Number System

Binary, Denary, Hexadecimal,and


02 Octal

03 Binary Addition and Subtraction

04 One's and Two's Complement

05 Binary Coded Decimal

06 Measurement of Size Memories

07 ASCII and Unicode


Number
System
A number system is defined as a system of 01 Decimal
writing to express numbers
The value of any digit in a number can be
determined by:
The digit
Its position in the number
The base of the number system Binary 02

03 Octal

Hexadecimal 04
Decimal
Example of Decimal Number System:
The decimal number system has a base of 10
because it uses ten digits from 0 to 9. The decimal number 1457 consists of the digit 7 in
In the decimal number system, the positions the units position, 5 in the tens place, 4 in the
successive to the left of the decimal point hundreds position, and 1 in the thousands place
represent units, tens, hundreds, thousands and whose value can be written as:
so on.
This system is expressed in decimal numbers. (1×103) + (4×102) + (5×101) + (7×100)
Every position shows a particular power of the (1×1000) + (4×100) + (5×10) + (7×1)
base (10). 1000 + 400 + 50 + 7
1457
Binary

The base 2 number system is also known as the Binary number system wherein, only two binary
digits exist, i.e., 0 and 1.
Specifically, the usual base-2 is a radix of 2.
The figures described under this system are known as binary numbers which are the
combination of 0 and 1.
these 2-digit number system is used to represent a set of data or information in discrete bits of
information.
For example, 110101 is a binary number.
Octal
Octal Digital Value Binary Equivalent

In the octal number system, the base is 8 and it 0 000

uses numbers from 0 to 7 to represent


1 001
numbers.
Octal numbers are commonly used in 2 010

computer applications. 3 011


Also in the aviation sector, Transponders used
in the aircraft transmit a code which is 4 100

expressed as four octal digit number. These 5 101


codes are interrogated by ground radar.
6 110

7 111
Hexadecimal
In the hexadecimal system, numbers are written or represented with base 16.
In the hexadecimal system, the numbers are first represented just like in the decimal system, i.e.
from 0 to 9. Then, the numbers are represented using the alphabet from A to F.
The below-given table shows the representation of numbers in the hexadecimal number system.

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

Decimal 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

Hexadecimal is used extensively in assembly programming languages and in machine code.


It is often used to refer to memory addresses.
It can be used during the debugging stage of writing a computer program and to represent numbers
stored in a CPU's registers or in main memory.
Decimal to Other

Example: Convert 26 into a binary number.


Example: Convert 6510 into an octal number. Example: Convert 127 to a
Divide 26 by 2
hexadecimal number.
Divide by 8
26/2 = 13 Remainder→0 (MSB)
13/2 = 6 Remainder →1
65/8 = 8 Remainder →1 (MSB) Divide by 16
127/16 = 7 Remainder →15
8/8 = 1 Remainder →0
7/16 = 0 Remainder →7
6/2 = 3 Remainder →0
⅛ = 0 Remainder →1 (LSB) In the hexadecimal number system,
3/2 = 1 Remainder →1 alphabet F is considered as 15.
Hence, the equivalent octal number is (101)8 Hence, 12710 is equivalent to 7F16
½ = 0 Remainder →1 (LSB)

Hence, the equivalent binary number is (11010)2


Other to Decimal

Example: Convert (11011) to decimal Example: Convert 121 base 8 into the Example: Convert 12 base 16 into a
number. equivalent decimal number. decimal number.

We need to multiply each binary digit with Here, we have to multiply each octal digit Multiply each digit with decreasing
the decreasing power of 2. with the decreasing power of 8, such as; power of 16 to obtain an equivalent
decimal number.
That is; 1×8^2+2×8^1+1×8^0
=1×2^4+1×2^3+0x2^2+1×2^1+1×2^0 1×16^1+2×16^0
=16+8+0+2+1 =64+16+1
=27 =16+2
=81
Therefore, (11011) = (27) =18
Binary to Octal
Octal to Binary

Step Binary Number Octal Number Step Octal Number Binary Number

Step 1 10101 010 101 Step 1 25 25

Step 2 10101 25 Step 2 25 010 101

Step 3 10101 25 Step 3 25 010101


Binary to Hexa
Hexa to Binary

Hexadecimal Hexadecimal
Step Binary Number Step Binary Number
Number Number

Step 1 10101 0001 0101 Step 1 15 15

Step 2 10101 15 Step 2 15 0001 0101

Step 3 10101 15 Step 3 15 00010101


Examples

Convert these binary numbers into denary Convert these denary numbers into binary

a) 0 0 1 1 0 011 a) 4 1
b) 0 1 1 1 1 111 b) 6 7
c) 1 0 0 1 1 001 c) 8 6
d) 0 1 1 1 0 100 d) 1 0 0
e) 1 1 1 1 1 111 e) 1 1 1
f) 0 0 0 0 1 111 f) 1 2 7
g) 1 0 0 0 1 111 g) 1 4 4
h) 0 0 1 1 0 011 h) 1 8 9
i) 0 1 1 1 0 000 i) 2 0 0
j) 1 1 1 0 1 110 j) 2 5 5
Examples

Convert these hexadecimal numbers into binary.


Convert these binary numbers into hexadecimal.
a) 6 C
a) 110000 1 1
b) 5 9
b) 111101 1 1
c) A A
c) 100111 1 1 11
d) A 0 0
d) 100111 0 1 11 0
e) 000111 1 0 000 1 e) 4 0 E
f) 100 0 1001111 0 f) B A 6
g) 001 0 0111111 1 0 g) 9 C C
h) 011 1 0100111 0 0 h) 4 0 A A
i) 111 1 1111011 1 1 10 1 i) D A 4 7
j) 001 1 0011110 1 0 11 1 0 j) 1 A B 0
Examples

Convert these binary numbers into denary Convert these denary numbers into binary

a) 0 0 1 1 0 011 a) 4 1
b) 0 1 1 1 1 111 b) 6 7
c) 1 0 0 1 1 001 c) 8 6
d) 0 1 1 1 0 100 d) 1 0 0
e) 1 1 1 1 1 111 e) 1 1 1
f) 0 0 0 0 1 111 f) 1 2 7
g) 1 0 0 0 1 111 g) 1 4 4
h) 0 0 1 1 0 011 h) 1 8 9
i) 0 1 1 1 0 000 i) 2 0 0
j) 1 1 1 0 1 110 j) 2 5 5
Addition and
Subtraction

A B A+B Carry A B A-B Borrow

0 0 0 0 0 0 0 0

0 1 1 0 0 1 1 1

1 0 1 0 1 0 1 0

1 1 0 1 1 1 0 0
One's and Two's
Complement
Examples

37 + 58
82 + 69
95 - 68
49 - 80
Examples
Carry out these binary additions and subtractions
using these 8-bit column weightings:

−128 64 32 16 8 4 2 1

a) 0011 1 0 0 1 + 0 0 1 0 1 0 0 1
b) 0100 1 0 1 1 + 0 0 1 0 0 0 1 1
c) 0101 1 0 0 0 + 0 0 1 0 1 0 0 0
d) 0111 0 0 1 1 + 0 0 1 1 1 1 1 0
e) 0000 1 1 1 1 + 0 0 0 1 1 1 0 0
f) 0110 0 0 1 1 − 0 0 1 1 0 0 0 0
g) 0111 1 1 1 1 − 0 1 0 1 1 0 1 0
h) 0011 0 1 0 0 − 0 1 0 0 0 1 0 0
i) 0000 0 0 1 1 − 0 1 1 0 0 1 0 0
j) 1101 1 1 1 1 − 1 1 0 0 0 0 1 1
Binary-coded decimal
(BCD) system
The binary-coded decimal (BCD) system uses
a 4-bit code to represent each denary digit:
Uses of BCD
0000= 0 The most obvious use of BCD is in the
representation of digits on a calculator or clock
0001= 1 display.
0010= 2 When it comes to accounting and representing
0011= 3 monetary values in computers, exact values
0100= 4 need to be stored to prevent significant errors
from accumulating.
0101= 5 Monetary values use a fixed-point notation, for
0110= 6 example $1.31, so one solution is to represent
0111= 7 each denary digit as a BCD value.
1000= 8
1001= 9
Examples

Carry out these BCD additions.

a) 0.45 + 0.21
b) 0.66 + 0.51
c) 0.88 + 0.75
Measurement of
Size Memories

Name of memory size Equivalent denary value (bytes) Name of memory size Equivalent denary value (bytes)

1 kilobyte (1KB) 1000 1 kibibyte (1KiB) 2^10

1 megabyte (1MB) 1000000 1 mebibyte (1MiB) 2^20

1 gigabyte (1GB) 1000000000 1 gibibyte (1GiB) 2^30

1 terabyte (1TB) 1000000000000 1 tebibyte (1TiB) 2^40

1 petabyte (1PB) 1000000000000000 1 pebibyte (1PiB) 2^50

You might also like