Article View: comp.lang.c.moderated
Article #2228Old meaning of "long double" declaration
From: Kevin Miller
Date: Sun, 10 Mar 1996 16:33
Date: Sun, 10 Mar 1996 16:33
64 lines
2635 bytes
2635 bytes
I compiled and ran the following code on my system to attempt
to find out how much precision existed in the various data types:
---------------------------------------------------------------------------
/* FUNCTION DECLARATIONS */
#include <stdio.h>
/* DEFINITION OF main */
#define TestNumber 7.53985739
int main (void) {
long double ldx;
ldx = TestNumber; /* The variable "ldx" should be a floating-point */
/* variable with at least as much precision as a */
/* variable of type "double". */
printf (" \n");
printf (" Size of int = %d \n", sizeof (int));
printf (" Size of long = %d \n", sizeof (long));
printf (" \n");
printf (" Size of double = %d \n", sizeof (double));
printf (" Size of long double = %d \n", sizeof (long double));
printf (" \n");
printf (" Size of ldx = %d \n", sizeof ldx);
printf (" Presumed Value of ldx = %10.8f \n", (double) TestNumber);
printf (" Actual Value of ldx = %10.8f \n", (double) ldx);
printf (" \n");
return 0; }
---------------------------------------------------------------------------
When I did, I got the following output:
---------------------------------------------------------------------------
Size of int = 4
Size of long = 4
Size of double = 8
Size of long double = 4
Size of ldx = 4
Presumed Value of ldx = 7.53985739
Actual Value of ldx = 7.00000000
---------------------------------------------------------------------------
Apparently, my damn compiler thinks that "long double" is an integer
data type. I guess it thinks "long double" is the same as "long (int)".
From reading the second (ANSI C) edition of K & R, I have concluded
that this is not correct as far as the ANSI standard is concerned.
What I am wondering is, previous to the ANSI standard, what, if
anything, was "long double" supposed to refer to? Is my compiler
consistent with some earlier definition of C, or is it just plain
squirrelly?
- Kevin Jay Miller
`
Technical Details
Message-ID:
<4hv08g$jep@solutions.solon.com>Path:
arc1-ca.pugleaf.net!solon.com!not-for-mailShow 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: Old meaning of "long double" declaration Date: 10 Mar 1996 10:33:20 -0600 Organization: University of California, Santa Barbara Sender: clc@solutions.solon.com Approved: clc@solutions.solon.com Message-ID: <4hv08g$jep@solutions.solon.com> NNTP-Posting-Host: solutions.solon.com