Mail Archives: djgpp/2001/05/15/03:36:38
Dennis Yelle wrote:
>
> Here is the program:
>
> #include <cmath>
> #include <cstdio>
> #include <iostream>
>
> long double f( long double x)
> {
> return pow( double(x), double( x*x*x));
> }
>
> [big snip]
>
> It looks like cout operator<< ignores the last 11 bits of a
> long double.
>
I'm thinking f() is the actual culprit.
For gcc 2.95.2, cmath simply includes math.h (though it has other
declarations, they are #if'ed out). math.h's pow() returns a double,
not a long double.
For gcc3, pow() is declared in cmath in many versions, including one
that returns a long double. However, unless the system library has
powl()
(and DJGPP doesn't seem to have it, according to math.h), it merely
returns the result of a regular pow() call, whis is defined as returning
a double.
No amount of upcasting can magically make higher precision appear.
--
Tim Van Holder - Falcon Software N.V.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
This message was posted using plain text. I do not endorse any
products or services that may be hyperlinked to this message.
- Raw text -