41.9k views
2 votes
What is the smallest integer n (stored as a floating point value) such that n + 1.0 - n will produce 0.0 for: a) Single-precision IEEE 754 floating point?

1 Answer

4 votes

Answer: The FP-s are stored as sign (1.)111111111111 - number of bits.

Also 24 bits resolution there can be 23 zeros

Step-by-step explanation:

The –1·2²⁴ might be stored as -1 · 1.00000000000000000000000(1 ←the 2⁰), it depends on how the FFP “engine” manages this, it may also be code specific a n+1–n does return 1 but 1–n+n does not. you should carry out a test for a specific compiler/computer

This is what javascript does with double (k+=1; n-=1) e.g

the (k+=2; n-=2) should be used to pass ±0x20000000000000

What is the smallest integer n (stored as a floating point value) such that n + 1.0 - n-example-1
What is the smallest integer n (stored as a floating point value) such that n + 1.0 - n-example-2
User Eldar Djafarov
by
4.2k points