Is Java.lang.Math "within 1 ULP" exclusive or included?

java.lang.Mathdocs speak for many functions, such as Math.pow:

The calculated result should be within 1 ulp of the exact result.

But I could not determine exactly what this means. Is it exclusive or comprehensive? In other words, if the exact result can be represented as double, will the return value contain the exact result or can it still be disabled by 1 ULP?

For example, can we rely on Math.pow(3.0, 2.0) == 9.0? I know that using equality comparison is almost always a bad idea for couples, so I mostly ask out of curiosity and can tell people their mistakes (or reassure them) when they do something like that.

+4
source share
1 answer

FYI,

, . ulps, . ulp - , . , , ulps . 0,5 ulps, , ; . , ; , .

Math 1 2 ulps . , 1 ulp error, , ; , , .

, , . , . 0,5 ulp : , , , , , , . , 1 ulp .

+6

All Articles