🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2272

Re: Old meaning of "long double" declaration

#2272
From: Kevin Miller
Date: Thu, 14 Mar 1996 02:20
42 lines
2334 bytes
The Amorphous Mass <robinson@blue.weeg.uiowa.edu> writes:

 # On 10 Mar 1996, Kevin Miller wrote:

 # > I compiled and ran the following code on my system to attempt 
 # > to find out how much precision existed in the various data types:  

 # [much snippage]

 # >    long double ldx; 
 # [...]
 # >    printf (" Actual Value of ldx    = %10.8f \n", (double) ldx); 

 #    If you want the actual value of ldx, use the %Lf format specifier, and 
 # drop the cast to double.

 # printf("  Actual value of ldx    = %10.8Lf\n", ldx);

No, you don't understand.  We don't know, a priori, what data type 
the compiler is using for "ldx".  (We would know, if this compiler 
were guaranteed to be ANSI compliant, but it isn't.)  If "ldx" is 
anything other than an extended-precision floating point number, then 
giving a "%Lf" format specifier to printf will cause it to misinterpret 
the bits that it sees in "ldx".  On the other hand, one would hope that 
the compiler itself would at least know what data type it is actually 
using for "ldx", and therefore one would expect that when asked to 
do a cast to double, it would make the conversion correctly regardless 
of whether "ldx" was an integral or a floating-point type.  I actually 
tried the "%Lf" specifier first.  Here is the result:  

 Size of ldx            = 4
 Presumed Value of ldx  = 7.53985739
 Actual Value of ldx    = 0.00000000

This is, in my opinion, an even "wronger" answer than the one I reported 
in my previous post.  Clearly, this compiler is not ANSI compliant.  What 
I wanted to know is whether there is some historical, pre-ANSI-standard 
justification for its behavior, or did its author's just plain screw up?  
Is it an old, but good, compiler?  Or is it just junk?  
 
                       - Kevin Jay Miller 
 ` 
Technical Details
Message-ID: <4i7vpi$42h@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4hv08g$jep@solutions.solon.com> <4i2jvf$8i9@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: kjm@sbphy.physics.ucsb.edu ( Kevin Miller)
Newsgroups: comp.lang.c.moderated
Subject: Re: Old meaning of "long double" declaration
Date: 13 Mar 1996 20:20:34 -0600
Organization: University of California, Santa Barbara
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4i7vpi$42h@solutions.solon.com>
References: <4hv08g$jep@solutions.solon.com> <4i2jvf$8i9@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com