Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 976315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:43:41+00:00 2026-05-16T03:43:41+00:00

I am trying to understand floating point arithmetic better and have seen a few

  • 0

I am trying to understand floating point arithmetic better and have seen a few links to ‘What Every Computer Scientist Should Know About Floating Point Arithmetic’.

I still don’t understand how a number like 0.1 or 0.5 is stored in floats and as decimals.

Can someone please explain how it is laid out is memory?

I know about the float being two parts (i.e., a number to the power of something).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:43:42+00:00Added an answer on May 16, 2026 at 3:43 am

    I’ve always pointed people towards Harald Schmidt’s online converter, along with the Wikipedia IEEE754-1985 article with its nice pictures.

    For those two specific values, you get (for 0.1):

    s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm    1/n
    0 01111011 10011001100110011001101
               |  ||  ||  ||  ||  || +- 8388608
               |  ||  ||  ||  ||  |+--- 2097152
               |  ||  ||  ||  ||  +---- 1048576
               |  ||  ||  ||  |+-------  131072
               |  ||  ||  ||  +--------   65536
               |  ||  ||  |+-----------    8192
               |  ||  ||  +------------    4096
               |  ||  |+---------------     512
               |  ||  +----------------     256
               |  |+-------------------      32
               |  +--------------------      16
               +-----------------------       2
    

    The sign is positive, that’s pretty easy.

    The exponent is 64+32+16+8+2+1 = 123 - 127 bias = -4, so the multiplier is 2-4 or 1/16.

    The mantissa is chunky. It consists of 1 (the implicit base) plus (for all those bits with each being worth 1/(2n) as n starts at 1 and increases to the right), {1/2, 1/16, 1/32, 1/256, 1/512, 1/4096, 1/8192, 1/65536, 1/131072, 1/1048576, 1/2097152, 1/8388608}.

    When you add all these up, you get 1.60000002384185791015625.

    When you multiply that by the multiplier, you get 0.100000001490116119384765625, which is why they say you cannot represent 0.1 exactly as an IEEE754 float, and provides so much opportunity on SO for people answering "why doesn't 0.1 + 0.1 + 0.1 == 0.3?"-type questions 🙂


    The 0.5 example is substantially easier. It’s represented as:

    s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm
    0 01111110 00000000000000000000000
    

    which means it’s the implicit base, 1, plus no other additives (all the mantissa bits are zero).

    The sign is again positive. The exponent is 64+32+16+8+4+2 = 126 - 127 bias = -1. Hence the multiplier is 2-1 which is 1/2 or 0.5.

    So the final value is 1 multiplied by 0.5, or 0.5. Voila!


    I’ve sometimes found it easier to think of it in terms of decimal.

    The number 1.345 is equivalent to

    1 + 3/10   + 4/100 + 5/1000
    

    or:

            -1       -2      -3
    1 + 3*10   + 4*10  + 5*10
    

    Similarly, the IEEE754 representation for decimal 0.8125 is:

    s eeeeeeee mmmmmmmmmmmmmmmmmmmmmmm
    0 01111110 10100000000000000000000
    

    With the implicit base of 1, that’s equivalent to the binary:

             01111110-01111111
    1.101 * 2
    

    or:

                         -1
    (1   + 1/2 + 1/8) * 2     (no 1/4 since that bit is 0)
    

    which becomes:

    (8/8 + 4/8 + 1/8) * 1/2
    

    and then becomes:

    13/8 * 1/2 = 0.8125
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I understand that floating point arithmetic as performed in modern computer systems is not
all I am trying to implement a floating point arithmetic library and I have
I'm trying to understand how floating point numbers work. I think I'd like to
I was trying to understand the floating point representation in C using this code
I'm trying to understand a paper on lossless compression of floating point numbers and
I have read most of the posts on here regarding floating point, and I
I have a variable in Python containing a floating point number (e.g. num =
Trying to understand an fft (Fast Fourier Transform) routine I'm using (stealing)(recycling) Input is
After trying to understand why client code is not rendered in a page (injected
I've been trying to understand how Ruby blocks work, and to do that I've

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.