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

Floating point number representation

How are floating numbers represented inside a computer

Uploaded by

Naren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Floating point number representation

How are floating numbers represented inside a computer

Uploaded by

Naren
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 27

Floating point number representation

How to represent a floating point number?


All values are stored in memory.
Memory is made a number of locations.
Each location is made of a register.
A register is made of D flip flops.
Floating point number representation
A 4 bit register is made of 4 flip flops.
D D D D This makes one memory location.

D D D D
Memory with 8 locations (words)
D D D D
with each location made of 4
D D D D
flip flops (bits).
D D D D

D D D D
8 X 4 Memory (8 locations with 4
D D D D words/location)
D D D D

D D D D
Floating point number representation
A flip flop can store only a bit which is 0 or 1.
So, to store the sign of the number we use the
Sign bit.
How to store real numbers (floating point
numbers) with integer and fractional parts
separated by a period?
12.34
Floating point number representation
There is a standard of representing floating point
numbers.
12.34 is represented as +1.234 X 101.
1.234 is written as +1.234 X 100.
How would you write the following numbers using
the above standard?
1) 0.01234
2) 123.4
3) 0.001234
Floating point number representation
1) 0.01234 = +1.234 X 10-2.
2) 123.4 = +1.234 X 102.
3) 0.001234 = +1.234 X 10-3.
How can 1234 represented using the above
standard?
1234 =
Floating point number representation
+1.234 X 10-2 has 2 parts: 1) Mantissa & 2)
Exponent
Which part in the above number is mantissa &
which is exponent.
Mantissa =
Exponent =
Floating point number representation
+1.234 X 10-2 has 2 parts: 1) Mantissa & 2)
Exponent
Which part in the above number is mantissa &
which is exponent.
Mantissa = 234
Exponent = -2
Floating point number representation
How to write +18.765 in Scientific notation.
+18.765 = +1.8765 X 101.
Note: When the decimal point moves to the left,
the exponent is +ve.
+1.8765 X 101 2 parts: 1) Mantissa & 2) Exponent
Which part in the above number is mantissa &
which is exponent.
Mantissa = 0.8765
Exponent = +1
Floating point number representation
How to write +0.18765 in Scientific notation.
+18.765 = +1.8765 X 10-1.
Note: When the decimal point moves to the right,
the exponent is -ve.
+1.8765 X 10-1 2 parts: 1) Mantissa & 2) Exponent
Which part in the above number is mantissa &
which is exponent.
Mantissa = 0.8765
Exponent = -1
Floating point number representation
How are floating point binary numbers
represented?
The method is slightly different with 32 bits for
single precision floating number.
S eeeeeeee mmmmmmmm mmmmmmmm
mmmmmmm
= First S is the sign of the exponent
Next 8 e are the exponent bits
Next 23 m are the mantissa bits
Floating point number representation
How is 4.5(10) represented in floating point
representation?
Floating point number representation
4.5(10) = 100.1(2)
1) This binary number is to be normalized first.
After normalization,
100.1(2) = 1.001(2) X 22.
Floating point number representation
Similarly when the number
0.000000001101(2) x 23 is normalized, it appears as
1.101(2) x 2-6
How would the number 0.00100101(2) be written
in normalized form?
Floating point number representation
How would the number 0.00100101(2) be written
in normalized form?
0.00100101(2) would be written as
1.00101 (2) X 2-3.
Floating point number representation
How would the number 110.11101(2) be written in
normalized form?
110.11101(2) would be written as
Floating point number representation
How would the number 110.11101(2) be written in
normalized form?
110.11101(2) would be written as
1.1011101 (2) X 22.
Floating point number representation
Step 1: is to normalize.
1.1011101 (2) X 22 is positive.
Hence, it can be written as (-1)0 as exponent 0 represents +ve number.

For a –ve number, (-1)1 would represent the –ve number. (exponent 1 represents -ve number. )

Step 2: Find the mantissa. To find the mantissa, we omit the integer 1.
Example:
In 1.1011101 (2) X 22 ,the mantissa is 1011101(2).
Make this mantissa as 23 bit number.
10111010000000000000000 by adding necessary 0s at the end.

Step 3: Find the biased exponent.


Add 127 to the exponent to get the biased exponent. So, biased exponent =127 + 2 = 129.
Represent this biased exponent as an 8 bit number. 10000001(2).
Floating point number representation
Step 4: Now write the 32 bit binary number in the
format sign (1 bit) e (8 bits) & m (23 bits).
So, 110.11101(2) would be written as
1 10000001 10111010000000000000000
Floating point number representation
How is 9.25(10) represented in floating point
representation?
Floating point number representation
9.25(10) = 1001.01(2)
1) This binary number is to be normalized first.
After normalization,
1001.01(2) = 1.00101(2) X 23.
Floating point number representation
Step 1: is to normalize.
1.00101(2) X 23 is positive.
Hence, it can be written as (-1)0 as exponent 0 represents +ve number.

For a –ve number, (-1)1 would represent the –ve number. (exponent 1 represents -ve number. )

Step 2: Find the mantissa. To find the mantissa, we omit the integer 1.
Example:
In 1.00101(2) X 23, the mantissa is 00101(2).
Make this mantissa as 23 bit number.
00101000000000000000000 by adding necessary 0s at the end.

Step 3: Find the biased exponent.


Add 127 to the exponent to get the biased exponent. So, biased exponent =127 + 3 = 130.
Represent this biased exponent as an 8 bit number. 10000010(2).
Floating point number representation
Step 4: Now write the 32 bit binary number in the
format sign (1 bit) e (8 bits) & m (23 bits).
So, 1001.01(2) would be written as
1 10000010 00101000000000000000000
Floating point number representation
Step 4: Now write the 32 bit binary number in the
format sign (1 bit) e (8 bits) & m (23 bits).
So, 1001.01(2) would be written as
1 10000010 00101000000000000000000
Floating point number representation
Represent 125.625(10) as the 32 bit floating point number.
Steps:
1) Find the binary equivalent of the decimal number.
2) Write the Binary number in normalized form.
3) Find the sign of the exponent.
4) Calculate the biased exponent. Convert this into 8 bit
binary number.
5) Write the fractional part of the normalized number as a
23 bit binary value.
6) Write s(ign)e(xponent)m(antissa) as 32 bit value.
Floating point number representation
Represent 125.625(10) as the 32 bit floating point number.
Steps:
1) 125.625(10) =
2) Write the Binary number in normalized form.
3) Find the sign of the exponent.
4) Calculate the biased exponent. Convert this into 8 bit
binary number.
5) Write the fractional part of the normalized number as a
23 bit binary value.
6) Write s(ign)e(xponent)m(antissa) as 32 bit value.
Floating point number representation
Represent 125.625(10) as the 32 bit floating point number.
Steps:
1) 125.625(10) = 1111101.101(10)
2) Binary number (normalized form):1.111101101(2) X 26
3) Sign of the exponent: (-1)0 = 1
4) Biased exponent: 127 + 6 = 133 = 10000101
5) 23 bit mantissa:11110110100000000000000 .
6) Write s(ign)e(xponent)m(antissa) as 32 bit value.
7) 32 bit floating number =
1 10000101 11110110100000000000000
Floating point number representation
Reference:
https://www.geeksforgeeks.org/floating-point-
representation-basics/

You might also like