swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Swarm-Support] Followup: found work-around for missing~/swarmarchiv


From: Marcus G. Daniels
Subject: Re: [Swarm-Support] Followup: found work-around for missing~/swarmarchiver.scm too
Date: Wed, 16 Aug 2006 19:10:59 -0600
User-agent: Thunderbird 1.5.0.5 (Windows/20060719)

Bill Northcott wrote:
On 16/08/2006, at 4:42 AM, Paul Johnson wrote:
Yesterday I was bug shooting a problem in and older FC4 and found that gcc treats 50 differently than 50.0 when used as a (double) parameter in a draw from a normal distribution, and the value 50 was converted to 0. It does not do that anymore in FC5.

C is a strongly typed language. You can't just feed an integer constant (50) to a function that expects a double and have any guarantee about what will happen. If you need a floating point argument, you have to use a floating point constant (50.0) or cast the integer. I would expect that recent gcc compilers will kick you about this sort of thing, unless of course you have turned the warnings off or just ignored them.
Let's consult ISSO/IEC 9899 http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf
--
6.3.1.4 Real floating and integer

1 When a finite value of real floating type is converted to an integer type other than _Bool, the fractional part is discarded (i.e. the value is truncated toward zero). If the value of the integral part cannot be represented by the integer type, the behavior is undefined. [50]

2 When a value of integer type is converted to a real floating type, if the value being converted can be represented exactly in the new type, it is unchanged. If the value being converted is in the range of values that can be represented but cannot be represented exactly, the result is either the nearest higher or nearest lower representable value, chosen in an implementation-defined manner. If the value being converted is outside the range of values that can be represented, the behavior is undefined.

[50] The remainder operation performed when a value of integer type is converted to unsigned type need not be performed when a value of real floating type is converted to unsigned type. Thus, the range of portable real floating values is (-1 Utype_MAX+1).
--

One way a problem could occur is if a prototype was missing. That is, if the compiler didn't have a declaration for the method. Or perhaps it is a bug in the compiler.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]