This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Strange results with -mfpmath=sse


Hello,

with the following program I get rather weird results using gfortran 4.3.0
and the options -mfpmath=sse -march=pentium3:

! chkassoc.f90 --
!???? Check associativity
!
program chkassoc
??? implicit none
??? integer, parameter :: wp = kind(1.0d0)
? ! integer, parameter :: wp = kind(1.0)
??? real(wp) :: x
??? real(wp) :: y
??? real(wp) :: z
??? integer? :: i
??? do i = 1,50
??????? x = 10.0 ** i
??????? y = - 10.0 ** i
??????? z = (x + 1.0_wp) + y
??????? write(*,*) i, z
??? enddo
end program

The result is:

?????????? 1?? 1.00000000000000
?????????? 2?? 1.00000000000000
?????????? 3?? 1.00000000000000
?????????? 4?? 1.00000000000000
?????????? 5?? 1.00000000000000
?????????? 6?? 1.00000000000000
?????????? 7?? 1.00000000000000
?????????? 8?? 1.00000000000000
?????????? 9?? 1.00000000000000
????????? 10?? 1.00000000000000
????????? 11?? 2049.00000000000
????????? 12?? 4097.00000000000
????????? 13?? 172033.000000000
????????? 14? -376831.000000000
????????? 15?? 13008897.0000000
????????? 16? -272564223.000000
????????? 17?? 1569325057.00000
????????? 18?? 15693250561.0000
????????? 19?? 19493552129.0000
????????? 20? -2004087734272.00
????????? 21? -20040877342720.0
????????? 22?? 221803691638784.
????????? 23? 2.218036907999232E+015
????????? 24 -1.384842787186278E+016
????????? 25? 4.379764746585375E+017
????????? 26 -2.537764285350674E+018
????????? 27? 1.151584525955262E+019
????????? 28? 5.578803098147996E+020
????????? 29 -1.504746630554518E+021
????????? 30 -1.504746619999206E+022
????????? 31? 1.517567923407867E+023
????????? 32 -3.318135346043450E+024
????????? 33? 5.504272659147238E+024
????????? 34? 2.097852315021449E+026
????????? 35 -4.091847879099609E+027
????????? 36? 3.830968379705522E+028
????????? 37? 6.618418702805115E+028
????????? 38? 3.197143073098154E+030
????????? 39?????????????? -Infinity
????????? 40?????????????? -Infinity
????????? 41?????????????? -Infinity
????????? 42?????????????? -Infinity
????????? 43?????????????? -Infinity
????????? 44?????????????? -Infinity
????????? 45?????????????? -Infinity
????????? 46?????????????? -Infinity
????????? 47?????????????? -Infinity
????????? 48?????????????? -Infinity
????????? 49?????????????? -Infinity
????????? 50?????????????? -Infinity

I could not check whether this has been solved in version 4.4 or 4.5, nor was
I able to find a similar error report on bugzilla.

The odd thing is that if I change the precision to single precision, then the
output is much more to what I expected: 1.0, 0.0 or NaN.

Regards,

Arjen

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]