[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #45481] rem and fmod may give very wrong resul
From: |
Alexander Klein |
Subject: |
[Octave-bug-tracker] [bug #45481] rem and fmod may give very wrong results for large arguments |
Date: |
Wed, 08 Jul 2015 08:23:29 +0000 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/534.59.10 (KHTML, like Gecko) Version/5.1.9 Safari/534.59.10 |
Follow-up Comment #2, bug #45481 (project octave):
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)
_______________________________________________________
Additional Item Attachment:
File name: conv_test.c Size:0 KB
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?45481>
_______________________________________________
Nachricht gesendet von/durch Savannah
http://savannah.gnu.org/