Re: Linux oddity
From: lilburne (lilburne_at_godzilla.net)
Date: 10/18/03
- Next message: David B. Held: "Re: template parameters in non-template class"
- Previous message: Ron Natalie: "Re: Linux oddity"
- In reply to: Keith S.: "Linux oddity"
- Next in thread: Keith S.: "Re: Linux oddity"
- Reply: Keith S.: "Re: Linux oddity"
- Reply: Mattias Ekholm: "Re: Linux oddity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sat, 18 Oct 2003 18:29:54 +0100
Keith S. wrote:
> Hi Folks,
>
> When converting a double to an int, the result is not as
> I'd expect on Linux:
>
> #include <stdio.h>
> int
> main(int argc, char **argv)
> {
> double val = 0.24;
> int multiplier = 2000;
> int result = static_cast<int> (val * multiplier);
> printf("result = %d (should be 480)\n", result);
> return 0;
> }
>
> The above code prints 480 on SunOS and Windows, but on
> Linux with gcc 3.2 it prints 479. Is there a valid
> explanation for this difference?
>
Check the status of the floating point chip. The calculation
may be being done with 80 bit precision in the first two
cases and 64 bit precision in the later case.
- Next message: David B. Held: "Re: template parameters in non-template class"
- Previous message: Ron Natalie: "Re: Linux oddity"
- In reply to: Keith S.: "Linux oddity"
- Next in thread: Keith S.: "Re: Linux oddity"
- Reply: Keith S.: "Re: Linux oddity"
- Reply: Mattias Ekholm: "Re: Linux oddity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|