Thursday 15 August 2013

Can a subtraction between two exactly represented floating point numbers with the same floating point be inexact? -



Can a subtraction between two exactly represented floating point numbers with the same floating point be inexact? -

i have 2 numbers, x , y, known , represented floating point numbers. want know if z = x - y exact or if rounding errors can occur. simple examples it's obvious:

x = 0.75 = (1 + 0.5) * 2^-1 y = 0.5 = 1 * 2^-1 z = x - y = 0.25 = 0.5 * 2^-1 = 1 * 2^-2

but if have x , y such all important digits used , have same exponent? intuition tells me result should exact, see kind of proof this. different if result negative?

i assuming want 2 numbers have same sign. if not, reply "yes"; consider (-1) - nextafter(1, infinity), works out -2 in floating-point arithmetic round-to-even.

under assumption, reply "no." (almost) special case of sterbenz's theorem: if x , y floating-point numbers of opposite signs such |y|/2 <= x <= 2|y|, x + y exactly-representable floating-point number.

i "almost" because statement works 0 , subnormal numbers.

floating-point floating-accuracy

No comments:

Post a Comment