www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/05/15/03:36:38

Sender: tim AT riker DOT skynet DOT be
Message-ID: <3B00DC4E.D5551973@falconsoft.be>
Date: Tue, 15 May 2001 09:35:42 +0200
From: Tim Van Holder <tim DOT vanholder AT falconsoft DOT be>
Organization: Falcon Software NV
X-Mailer: Mozilla 4.77 [en] (X11; U; Linux 2.2.16-3 i686)
X-Accept-Language: en, nl-BE, nl
MIME-Version: 1.0
To: Dennis Yelle <dennis51 AT jps DOT net>
CC: djgpp AT delorie DOT com
Subject: Re: cout ignores the last 11 bits of long double
References: <3AFC71C1 DOT D3CDF864 AT jps DOT net>
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019