We will study how fractional numbers are represented inside a computer next
I will use fixed point decimal numbers to introduce ("ease into") the fixed point binary numbers
|
Example:
Decimal number: 123.45
^^^ ^^
||| ||
||| |+--- weight = 1/100
||| +---- weight = 1/10
||+------- weight = 1
|+-------- weight = 10
+--------- weight = 100
|
Structure of a fixed point binary number:
|
Example:
Binary number: 101.01
^^^ ^^
||| ||
||| |+--- weight = 1/4
||| +---- weight = 1/2
||+------- weight = 1
|+-------- weight = 2
+--------- weight = 4
|
Method: compute the value using decimal arithmetic
Example:
Binary number: 101.01
^^^ ^^
||| ||
||| |+--- weight = 1/4
||| +---- weight = 1/2
||+------- weight = 1
|+-------- weight = 2
+--------- weight = 4
The value represented by 101.01(2) is:
1*(4) + 0*(2) + 1*(1) + 0*(1/2) + 1*(1/4) = 5 1/4
= 5.25(10)
|
Method:
|
It's easier to understand the method using an example (next slide)
Convert 23.6875(10) to fixed point binary representation:
|
(Worked on on next slide)
I will do this example in the lecture (using paint as writing board)
|
Comments:
|