Subject: arithmetic oddness in mac68k port
To: None <port-mac68k@NetBSD.ORG, misc@openbsd.org>
From: Paul DuBois <dubois@primate.wisc.edu>
List: port-mac68k
Date: 06/12/1997 11:51:27
I have a small program:
#include <stdio.h>
void
subr (double x)
{
long l;
l = x * 60;
printf ("%ld\n", l);
}
main ()
{
long l;
l = (1./3.) * 60;
printf ("%ld\n", l);
subr (1./3.);
}
Under SunOS 4.1.1 (SPARC), Solaris 2.5 (SPARC), RISC/os 4, or HP-UX 9,
this program prints "20" and "20". Under NetBSD/mac68k 1.2D or
OpenBSD/mac68k 2.1 it prints "20" and "19". The program is contrived,
of course, but seems to indicate something odd that occurs in passing
a double (1./3.) as an argument that does not happen when the double
is used directly. gcc was used on all machines.
Is this something specific to the Macintosh versions of xxxBSD, perhaps?
--
Paul DuBois
dubois@primate.wisc.edu
Home page: http://www.primate.wisc.edu/people/dubois
Software: http://www.primate.wisc.edu/software