0% found this document useful (0 votes)
23 views

Number Systems - Data Representation (Numbers)

The document discusses various methods of representing numeric data in digital systems including binary, binary coded decimal, unpacked decimal, packed decimal, sign-magnitude, fixed point, and floating point representations. Floating point representation is explained in detail including biasing exponents and converting decimal numbers to the IEEE 754 floating point format.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

Number Systems - Data Representation (Numbers)

The document discusses various methods of representing numeric data in digital systems including binary, binary coded decimal, unpacked decimal, packed decimal, sign-magnitude, fixed point, and floating point representations. Floating point representation is explained in detail including biasing exponents and converting decimal numbers to the IEEE 754 floating point format.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Data Representation

NUMBERS
Introduction

Computers and other digital circuits process data in binary


format.

Various binary codes are used to represent data which


maybe numeric, alphabetic or special characters.

In digital systems in every code used, the information is


represented in binary form, but the interpretation of the data
is only possible if the code in which the data is being
represented is known.

10000102 = 66 (decimal) in straight binary


= 42 in Binary Coded Decimal
= B in ASCII code
Numeric Representation

Decimal Digit Representation

1) Binary Coded Decimal (BCD)

2) Unpacked Decimal Format

3) Packed Decimal Format


Numeric Representation

Decimal Digit Representation

Binary Coded Decimal (BCD) - coding scheme relating


decimal and binary numbers. Four (4) bits are required to
code each decimal number
Examples
789 --→ 0111100010012

7 8 9
0111 1000 1001

105 → 1000001012

0001 0000 0101


Numeric Representation

Decimal Digit Representation

Unpacked Decimal Format - also called zoned decimal format

➢ Uses 1 byte for each digit of the decimal number


➢ Represents the values 0 to 9 in the least significant 4 bits of 1
byte
➢ In the most significant 4 bits, called the zoned bits, 1111 is stored
➢ The 4 bits that represent the sign is stored in the zoned bits of
the least significant digit (Positive and 0 is represented by 1100
while negative is 1101)
Examples
789 →

7 8 9
11110111 11111000 11001001

-105 →

1 0 5
11110001 11110000 11010101
Numeric Representation

Decimal Digit Representation

Packed Decimal Format -

➢ One 1 byte represents 2 digits of the decimal number


➢ The least significant 4 bits represent the sign
▪ The bit pattern of the sign is the same as that of the
unpacked decimal format , Positive and 0 is
represented by 1100 while negative is 1101
Examples
789 →

7 8 9 +(sign bit)
0111 1000 1001 1100

-105 →

1 0 5 - (sign bit)
0001 0000 0101 1101
Examples
1789 →

1 7 8 9 +(sign bit)
0000 0001 0111 1000 1001 1100

1 byte 1 byte 1 byte


Numeric Representation

1) Signed Binary Numbers


- Signed Magnitude

2) Fixed Point

3) Floating Point
Sign-magnitude Representation

An additional bit is used as the sign bit, usually


placed as the MSB (most significant bit)

Generally 0 is reserved for positive a 1 is reserved


for a negative number.

Examples
Magnitude : 1011002 = 4410
01011002 = +4410
Magnitude : 1112 = 710
11112 = -710
The sign-magnitude binary format is the simplest
conceptual format. In this method of representing
signed numbers, the most significant digit (MSD) takes
on extra meaning.

•If the MSD is a 0, we can evaluate the number just as


we would any normal unsigned integer. And also we
shall treat the number as a positive one.
•If the MSD is a 1, this indicates that the number is
negative.
FIXED POINT vs FLOATING POINT

A fixed point number just means that there are a fixed number of
digits after the decimal point. A floating point number allows for a
varying number of digits after the decimal point.

For example, if you have a way of storing numbers that requires


exactly four digits after the decimal point, then it is fixed point.
Without that restriction it is floating point.

Floating point numbers are more general purpose because they can
represent very small or very large numbers in the same way, but
there is a small penalty in having to have extra storage for where
the decimal place goes.

https://stackoverflow.com/questions/7524838/fixed-point-vs-floating-point-number
Floating Point

➢ Used to represent real number data type


➢ Normally used for scientific and engineering fields
requiring complicated calculations
➢ Represents either extremely large or small size of
data

Example:
1,500,000,000 - instead of writing 8 zeroes, this is written
as 15 X 108
In floating point, it would be written as
1.5 X 109 Exponent

Mantissa Radix
Steps in Decimal to Floating Point Conversion (IEEE)
(IEEE - Institute of Electrical and Electronics Engineering)

Step 1 : Convert decimal number to binary

Example : 510 -> 1012


Step 2 : Write the binary number in scientific notation
or floating point format (normalized)

Example : 510 -> 1012


510 -> 1012 -> 1.01 X 22

A floating point number is normalized when we force


the integer part of its mantissa to be exactly 1
Step 3 : Write the number in IEEE floating point
representation

Floating point representation

S Exponent Mantissa portion (23 bits)


portion
(8 bits)

Sign bit
0-positive Only binary fraction, lower
1-negative than 1 can be represented

Radix is 2
Step 3 : Floating point representation
Exponent Portion

Example : 510 -> 1012 -> 1.01 X 22


The exponent portion
To bias exponent in IEEE, add 127 to the exponent
(see next slide for the explanation of biasing the exponent)

• Bias the exponent by adding 127 ---> 2 + 127 = 129


• And convert to binary, 129 ---> 10000001

0 10000001

Sign Bit Biased Exponent


Biasing of Exponent

➢ Is used to be able to represent both positive and


negative exponents to be represented as positive
n-bit integers

➢ To get the biased exponent in IEEE, add the bias


which is 127 to the exponent.*

The bias of 127 is taken from


the formula 2n-1 - 1 where n is the number
of bits of the exponent which is 8

* Bias of 127 is for single precision floating point, IEEE 754


Step 3 : Floating point representation
Mantissa Portion

Example : 510 -> 1012 -> 1.01 X 22

The mantissa portion


The binary fraction equivalent to the mantissa -1 is registered.
In other words, 1 is considered to be omitted.

1.01 - 1 = .01

0 10000001 01000000000000000000000
Example # 2

Step 1 : Get the binary equivalent of the decimal


number
.0937510 -> .000112

0.09375 X 2 = 0.1875
0.1875 X 2 = 0.375
0.375 X 2 = 0.75
0.75 X 2 = 1.5
0.5 X 2 = 1.0
Example # 2

Step 2 : Write the binary number in scientific notation

.0937510 -> .000112 -> 1.1 X 2-4


Step 3 : Write the number in floating point format

.0937510 -> 0.000112 -> 1.1 X 2-4

0 01111011 10000000000000000000000

For the exponent,


Bias the exponent and convert to binary.

-4 - > 127 + (-4) = 123 -> 01111011 (biased)

For the mantissa,


1.1 - 1 = 0.1
Example 3: 32.125
Step 2 : Get the scientific notation of the number
32.12510 = 100000.0012

In scientific notation 1.00000001 X 25

Step 3 : Write in floating point format

0 10000100 000000010000000000000
References:

Introduction to Computer Systems


Japan Information-Technology Engineers Examination Center
Information-Technology Promotion Agency, Japan

https://www.wikihow.com/Convert-a-Number-from-Decimal-to-IEEE-754-
Floating-Point-Representation

You might also like