On 3 February 2012 18:12, Konstantin Vladimirov <konstantin.vladimi...@gmail.com> wrote: > Hi, > > I agree, that this case have no practical value. It was autogenerated > between other thousands of tests and showed really strange results, so > I decided to ask. I thought, this value fits double precision range > and, according to C standard, all double-precision arithmetics must be > avaliable for it. > > Thanks everybody for explanation, I will constrain trig function > arguments, according to "x is separable with x+pi/4" rule. It seems, > everything works inside this range. >
The important bit is ensuring the input can be represented in 52 bits of precision of the double floating point number. The higher the input number, the fewer discrete real values you can represent in the 0 to pi/4 range. I will try to explain in base 10, with 3 digits of precision. Take the range change to between 0 to 9 (instead of 0 to pi/4) Input value 3.21, no range change (like a "n mod 10" but for reals) needed, I can have input after the range change of values 1.00, 1.01, 1.02 ... 3.21 ... 9.99. I.e 1000 discrete values between 0 and 10. Input value 32.1, range change to 2.1, I can have input values 1.0, 1.1, 1.2, ... 9.9. I.e. Only 100 discrete values between 0 and 10. Input value 321, range change to 1, I can have input values of 1, 2, 3, ... 9. I.e. Only 10 discrete values between 0 and 10. Input value 3210, range change to 0, I can have input values of 0. I.e. Only 1 discrete value between 0 and 10. Input value 32100... etc. (note the 3 digits of precision) Kind Regards James