g77 bug: int(log10(x))
Billinghurst, David (CRTS)
David.Billinghurst@riotinto.com
Thu Oct 18 15:41:00 GMT 2001
This look like a floating point rounding issue.
Refer your user to "What Every Computer Scientist Should Know about
Floating-Point Arithmetic" - there is a link from
http://gcc.gnu.org/readings.html - or suggest they try using NINT function
to find the nearest integer.
-----Original Message-----
From: Patrick Lamb [ mailto:lamb@huntsville.sparta.com ]
Sent: Friday, 19 October 2001 7:26
To: gcc-bugs@gcc.gnu.org
Subject: g77 bug: int(log10(x))
Apologies if this has been covered already. One of my users presented
me with a test case of:
program test
implicit real*8 (a-h,o-z)
a=10.
b=log10(a)
i=int(b)
j=int(log10(a))
write(6,*)a,b,i,j
stop
end
When compiled with no optimization and run, the output is
10. 1. 1 0
with -O2 optimization, the result is
10. 1. 0 0
The platform is GNU Fortran 0.5.25 19991024 (part of a gcc 2.95.2
install) on an intel Linux box. The problem can be worked around by
using aint instead of int, but this still looks like a bug to me.
Pat
--
It is poor civic hygiene to install technologies that could someday
facilitate a police state. -- Bruce Schneier
Patrick Lamb, Ph.D. lamb@huntsville.sparta.com
(256) 837-5282 x1253 voice, (256) 830-0287 FAX
-----BEGIN GEEK CODE BLOCK-----
Version: 3.12
GS/MU/FA/PA/CS/E d+() s+:++ a+ C++() UL++++$ P++>+++ L+++(++) E(+)
W++@(+) N++ K? w(---) O M- PS+(++) PE Y+ PGP>+ t 5? X? R tv(+) b++(+++)
DI++(++++) D+ G e++++ h--- r+++ y++++
------END GEEK CODE BLOCK------
More information about the Gcc-bugs
mailing list