Andreas Schwab wrote:
>> No, this is not portable,
> 
> Sure they are, since they are required since C89.
> 
> You can use <float.h> to find that out.  That's what portability is
> about.

"Portability" means different things to different people. There's a
difference between source code portability and "result" portability.

If you follow Standard C, you are guaranteed source code portability, in
the program compiles and produce the "same" results with any Standard C
compiler.

When we start talking about floating-point code, however, we enter the
realm of "result" portability, in that different platforms (or different
compiler swicthes) return slightly different numbers from the same
source code.

An example of this is the use of long double, the implementation of
which differs from platform to platform. On Intel-inspired processors, a
long double is 80 bits long with a 64-bit mantissa, corresponding to the
x87 registers. On other systems, long double may be the same as double,
having 64 bits and a 53-bit mantissa. Calculations with 80-bit long
doubles will differ from the same computations performed using 64-bit
long doubles.

C does not enforce identical results on all platforms; Java does (or at
least tries to).

It's an easy problem to get tripped by, as I recently experienced on
this forum.

..Scott

Reply via email to