Subject: toolchain/21414: double to unsigned int conversion broken
To: None <gnats-bugs@gnats.netbsd.org>
From: Martin Husemann <martin@duskware.de>
List: netbsd-bugs
Date: 05/01/2003 19:55:32
>Number: 21414
>Category: toolchain
>Synopsis: double to unsigned int conversion broken
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu May 01 17:56:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator: Martin Husemann
>Release: NetBSD 1.6R
>Organization:
>Environment:
System: NetBSD sunny-weather.duskware.de 1.6R NetBSD 1.6R (SUNNY) #4: Thu May 1 13:49:15 CEST 2003 martin@sunny-weather.duskware.de:/usr/src/sys/arch/sparc64/compile/SUNNY sparc64
Architecture: sparc64
Machine: sparc64
>Description:
The below test program outputs
ul = 567686, dtemp = 2438192804.397056, result = 0x7fffffff
on sparc64, while it (correctly) prints
ul = 567686, dtemp = 2438192804.397056, result = 0x9153dea4
on alpha and i386.
This has been noticed by Frank Kardel in PR port-sparc64/21406 as ntpd
lossage (that PR is suspended until this is fixed, please reexamine it when
the toolchain is fixed)
>How-To-Repeat:
Compile and run this:
main()
{
unsigned long ul = 567686;
unsigned int oul;
double dtemp;
dtemp = ul * 4294967296. / 1e6;
oul = (unsigned int)dtemp;
printf("ul = %ld, dtemp = %f, result = 0x%x\n", ul, dtemp, oul);
}
>Fix:
n/a
>Release-Note:
>Audit-Trail:
>Unformatted: