Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

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

  1. Aug 30, 2014 #1

    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.


    (image not embedded because it is too big and breaks the thread)
  2. jcsd
  3. Aug 30, 2014 #2
    long story short, i'm trying to figure out how

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

    without using computer
  4. Aug 31, 2014 #3


    User Avatar
    Science Advisor
    Gold Member
    2017 Award

    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
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook

Similar Threads for someone explain textbook
Python (VPython) Can someone help me with my orbit simulator?