Subject: Re: toolchain/21414: double to unsigned int conversion broken
To: None <netbsd-bugs@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 05/01/2003 19:35:42
> >Synopsis:       double to unsigned int conversion broken
> 
> The below test program outputs 
>   ul = 567686, dtemp = 2438192804.397056, result = 0x7fffffff
> on sparc64,
> 
>   dtemp = ul * 4294967296. / 1e6;
> 
>   oul = (unsigned int)dtemp;

Someone better check the C standard closely, K&R2 says:

    "When a value of floating type in converted to integral type, the
    fractional part is discarded; if the resulting value cannot be
    represented in the integral type, the behaviour is undefined."

So 0x7fffffff is fine...

	David

-- 
David Laight: david@l8s.co.uk