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

1. Aug 30, 2014

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)

2. Aug 30, 2014

long story short, i'm trying to figure out how

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

without using computer

3. Aug 31, 2014

### FactChecker

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 lets 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: Aug 31, 2014