Just a little background:
I wrote a program that does high accuracy factorials. It saves a given factorial for later use as a double precision real between 1 and 2 and an integer power of 2. It does this by calculating the factorial to a practically unlimited number of bits, rounding it to 53 bits only as the final step, thereby avoiding the cumulative round off errors that occur.
I wanted to compare the accuracy of this method to a straight-forward way of calculating factorials. So I also scaled factorials calculated in a straight-forward way the same way as above, that is as a double precision real between 1 and 2 and an integer power of 2.
In the comparison, the integer power of 2 can be ignored, as it is practically always the same. As to the real portion, the difference between the two reals should always be an integer multiple of 2**(-52). The crux of the bug is that when I compiled using the flag -O, this was true. Using -O2, it was not. Stated another way, the calculation of small differences seems to depend on optimization flags.
Created attachment 21388 [details]
Created attachment 21389 [details]
Created attachment 21390 [details]
Implicit typecasting include file
Created attachment 21391 [details]
Compilation batch file
You do not say on which platform you did the tests (gfortran -v). From
I assume that you are using some *86* processor under Windows.
This is not a gfortran bug, but a duplicate of an infamous pr I cannot find the number. You should try -ffloat-store or -mfpmath=sse and have a look at the gcc manual
under -ffloat-store and -fexcess-precision=style.
This is a duplicate of PR 323
Just use -ffloat-store.
*** This bug has been marked as a duplicate of 323 ***