Are all numbers with the same precision presented in double precision format?

Given an arbitrary number represented in the IEEE-754 single-precision format (commonly called float on some languages ​​/ platforms), can I be sure that the number can be represented exactly in double-precision format?

If this is the case, is this property valid when considering polarity with accuracy up to accuracy and double accuracy up to parity?

+6
source share
2 answers

Yes, double can represent any number that can float. Similarly for parity, etc.

A floating point number is represented in the form as 1.01bx 2^-1 (0.625, in this case). Significant components of a number are the value, which is basically a binary number with a number notation, usually immediately after the first digit, and an exponent.

The only significant difference between binary floating point formats is the number of bits for each component. The more bits a number is used, the more bits are available for each part. Thus, a 32-bit "float" can have 1.01000000000000000000000 for significant, and (a "64-bit" "double" will have about 50 digits after the dot. This means that any number that is exactly represented in the float is also accurately represented in double, because you have both increased accuracy (reading: more significant digits) and an increased range, this is similar to how a 64-bit integer variable can contain any 32-bit integer; the extra bits are largely unused.

Of course, any bits that were chopped off due to a rounding error will not be returned back to a number when converting to the double value 0.3 that you have in your float, being an inaccurate result, for example, 0.2999999875 or something (I I don’t want to calculate), I’m not going to approach 0.3 when you convert it to double - it will still remain 0.2999999875. If you want a closer approximation, you will need to repeat the doubling calculations from the start.

+5
source

Yes. In fact, you can make an even stronger statement: each product of two numbers with the same precision appears exactly in double precision (the same for half and one or two and four).

+3
source

Source: https://habr.com/ru/post/898658/


All Articles