Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

How many decimal digits are needed to represent a binary floating-point number as an exact fraction?

0
Posted

How many decimal digits are needed to represent a binary floating-point number as an exact fraction?

0

Excluding the exponent, you need as many decimal digits as there are binary bits in the significand of the binary floating-point number (you get one power of two in each digit). For example, the 64-bit IEEE 754 binary floating-point format (often called a ‘double’) has a 53-bit significand (52 bits explicit in the format and one implied). To represent this exactly needs 53 decimal digits. Here’s a brief proof-by-example: Consider the double which has all ones and an exponent of zero; that is, the binary fraction 1.1111111…. (53 one bits in all). That has the value 20 + 2−1 + 2−2 + …. + 2−52. Now consider the first and last terms of that expansion: 20 = 1 2−52 = 0.0000000000000002220446049250313080847263336181640625 The total must be less than 2, so the first term (1) provides the leftmost digit of the total. Also, no term is smaller than 2−52, so there will be no digits further to the right than those of that term. The sum of these two terms is: 1.0000000000000002220446049250313080

Thanksgiving questions

*Sadly, we had to bring back ads too. Hopefully more targeted.