Could someone explain this textbook example regarding float fl(x)

AI Thread Summary
The discussion centers on understanding how to compute the floating-point representation of 9.4, specifically how fl(9.4) is derived as 9.4 + 0.2 x 2^(-49). The binary representation of 9.4 is established as 1001.0110 0110 0110, with the decimal portion repeating. The confusion arises after discarding the infinite tail, where the rounding to the nearest rule is applied, leading to the addition of a small value. The explanation clarifies that the truncated part corresponds to 0.4 x 2^(-48), and the rounding adds a value of 2^(-49), resulting in the final expression. Overall, the arithmetic involved in combining these elements leads to the correct floating-point representation.
catsarebad
Messages
69
Reaction score
0
Hi,

okay here's the problem:

*find fl(x) for 9.4*

and here's how it's done

9.4 in binary is 1001.0110 0110 0110 since
9 = 1001
.4 = .0110 0110 0110... (basically, 0110 repeating)

next using Rounding to Nearest Rule (see top on picture) we get what a binary number (boxed in black in the picture below)

I understand how to do upto here perfectly however I do not understand what happens after that.

I'm confused by pretty much the entire thing that follows after "discarding the infinite tail". I do not understand how fl(9.4) turns out to be 9.4 + 0.2 x 2^(-49) (shown in red box in the picture).

could anyone provide explanation for this?

the book has another example similar to this but i couldn't follow either of them. i hope someone can explain me the basics of what is happening here.

http://i.imgur.com/IOpfVjm.jpg

(image not embedded because it is too big and breaks the thread)
 
Technology news on Phys.org
long story short, I'm trying to figure out how

fl(9.4) = 9.4 + 0.2 x 2^(-49)

without using computer
 
I'll take a stab at it:
The binary representation of 9.4 is standardized so that the leading digit before the decimal point is 1. That is how it will be stored in the computer and it let's you know how much will be truncated. The truncated part is a bit pattern that amounts to 0.4x(2^-48). The fl rule for rounding adds a digit that amounts to 2^-49. So the final bit pattern amounts to

9.4 + rounded - truncated = 9.4 + 2^-49 - 0.4 x (2^-48).

The rest is arithmetic.
 
Last edited:
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I have a quick questions. I am going through a book on C programming on my own. Afterwards, I plan to go through something call data structures and algorithms on my own also in C. I also need to learn C++, Matlab and for personal interest Haskell. For the two topic of data structures and algorithms, I understand there are standard ones across all programming languages. After learning it through C, what would be the biggest issue when trying to implement the same data...
Back
Top