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 4002986
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T08:05:51+00:00 2026-05-20T08:05:51+00:00

Please take a look at the following content: I understand how to convert a

  • 0

Please take a look at the following content:

enter image description here

I understand how to convert a double to a binary based on IEEE 754. But I don’t understand what the formula is used for.

Can anyone give me an example when we use the above formula, please?

Thanks a lot.

  • 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-20T08:05:51+00:00Added an answer on May 20, 2026 at 8:05 am

    The formula that is highlighted in red can be used to calculate the real number that a 64-bit value represents when treated as a IEEE 754 double. It’s only useful if you want to manually calculate the conversion from binary to the base-10 real number that it represents, such as when verifying the correctness of a C library’s implementation of printf.

    For example, using the formula on 0x3fd5555555555555, x is found to be exactly 0.333333333333333314829616256247390992939472198486328125. That is the real number that 0x3fd5555555555555 represents.

    #include <stdio.h>
    #include <stdlib.h>
    
    int main()
    {
      union {
        double d;
        unsigned long long ull;
      } u;
    
      u.ull = 0x3fd5555555555555L;
      printf("%.55f\n", u.d);
    
      return EXIT_SUCCESS;
    }
    

    http://codepad.org/kSithgZQ

    EDIT: As Olof commented, an IEEE 754 double exactly represents the value x in the equation, but not all real numbers are exactly representable. In fact, only a finite number of reals such as 0.5, 0.125, and 0.333333333333333314829616256247390992939472198486328125 are exactly representable, while the vast majority (uncountably many) including 1/3, 0.1, 0.4, and π are not.

    The key to knowing whether a real is exactly-representable as an IEEE 754 double is to calculate the real number’s binary representation and write it in scientific notation (e.g. b1.001×2-1 for 0.5625). If the number of binary digits to the right of the decimal point excluding trailing zeroes is less than or equal to 52 and the exponent minus one is between -1022 and +1023, inclusive, then the number is exactly representable.

    Let’s go through a couple of examples. Note that it helps to have an arbitrary-precision calculator on hand. I will use ARIBAS.

    1. The number 1/64 is 0.015625 in decimal. To calculate its binary representation, we can use ARIBAS’ decode_float function:

       ==> set_floatprec(double_float).
      -: 64
      
      ==> 1/64.
      -: 0.0156250000000000000
      
      ==> set_printbase(2).
      -: 0y10
      
      ==> decode_float(1/64).
      -: (0y10000000_00000000_00000000_00000000_00000000_00000000_00000000_00000000, 
      -0y1000101)
      
      ==> set_printbase(10).
      -: 10
      
      ==> -0y1000101.
      -: -69
      

      Thus 1/64 = b0.000001, or b1.0×2-6 in scientific notation.

      1/64 is exactly-representable.

    2. The number 1/10 = 0.1 in decimal. To calculate its binary representation:

      ==> set_printbase(2).
      -: 0y10
      
      ==> decode_float(1/10).
      -: (0y11001100_11001100_11001100_11001100_11001100_11001100_11001100_11001100, 
      -0y1000011)
      
      ==> set_printbase(10).
      -: 10
      
      ==> -0y1000011.
      -: -67
      

      So 1/10 = 0.1 = b0.0001100 (where bold represents a repeating digit sequence), or b1.1001100×2-4 in scientific notation.

      1/10 is not exactly-representable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

probably a no-brainer, but please take a look at the following classes / Interfaces:
Please take a look at the following .htaccess ErrorDocument 404 /404/ RewriteEngine On RewriteRule
Please take a look at following code: #include <stdio.h> #include <iostream> using namespace std;
Please take a look at the following line <TextBox Text="{Binding Price}"/> This Price property
Please take a look on the following example: class Base { protected: int m_nValue;
Please take a look at the following code: Public Sub Method(Of TEntity As EntityObject)(ByVal
Please take a look at the following fiddle: http://jsfiddle.net/ellenchristine/tty3e/ Note that when you expand
Would someone please take a look at the following code fragments (all from one
please take a look at the following snippet: public IEnumerable<T> Query(Expression<Func<T, bool>> filter) {
Please take a look at following code: public class SomeEntity { public int Id

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.