Subject: Re: arithmetic oddness in mac68k port
To: Paul DuBois <dubois@primate.wisc.edu>
From: David Brownlee <abs@anim.dreamworks.com>
List: port-mac68k
Date: 06/13/1997 09:44:19
	Maybe this is a float/double issue?
	The first '(1./3.) * 60' might be done all in floats while the
	second calculate in subr must be done in doubles...

		David

- "It was at that point I realised there might be a chance for myself as a
-  caring human being. Unable to decide whether to feel hopeful or disgusted,
-  I chose both and opened a bottle of wine to celebrate"

On Thu, 12 Jun 1997, Paul DuBois wrote:

> 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
>