Wed 08 Jul 2015 08:23:29 AM UTC, comment #2:
I'm reasonably confident that 4 is the correct answer for doubles.
The result by fmod_test has rounding errors creeping up above 1e22, but the remainders produced by fmod are consistent with the output of printf, and of lower magnitude than the divisor, at least.
I get 4 as the last digit with clang on FreeBSD as well as with gcc on OSX, but it may be worth noting that things are different for floats or long doubles, see attached program.
For OSX I get the following result, which is likely correct:
OSX% ./a.out
inf
inf
100000000000000003502199685943161173046080317798311825604870144
100000000000000003502199685943161173046080317798311825604870144
100000000000000000000982689773853339824972548992519069165944832
100000000000000000000982689773853339824972548992519069165944832
On FreeBSD, things go haywire, somewhat, insofar as the result of powf should have been Inf because it is larger than MAXFLOAT, and the result of powl is equal to the result of pow:
$ cc conv_test.c -lm
/tmp/conv_test-cca105.o: In function `main':
conv_test.c:(.text+0xf9): warning: powl has lower than advertised precision
$ ./a.out
inf
1000000030094932666179617348410047823344959136071346133401600
100000000000000003502199685943161173046080317798311825604870144
100000000000000003502199685943161173046080317798311825604870144
100000000000000000000982689773853339824972548992519069165944832
100000000000000003502199685943161173046080317798311825604870144
(file #34391)
|