Article View: comp.std.c
Article #1514Re: What is permissable with HUGE_VAL
From: Ray Butterworth
Date: Thu, 19 Jul 1990 20:49
Date: Thu, 19 Jul 1990 20:49
28 lines
1483 bytes
1483 bytes
If I remember the discussion about this from a year or two ago,
there was nothing in the standard indicating what HUGE_VAL needed
to be, other than positive.
i.e. there is no reason (other than the obvious sillyness) that
an implementation can't define HUGE_VAL as 5.2.
If you think no one would be silly,
consider the BSD definition of HUGE in their <math.h>:
#define VALUE (4.15383748682786205e34 * 4096)
/* from <math.h> */
#define HUGE 1.701411733192644270e38
main() {
auto double huge = HUGE;
auto double value = VALUE;
if (value > huge)
printf("value is bigger than huge\n");
if (value < huge)
printf("value is less than huge\n");
}
Because of the nature of floating point it wouldn't be unreasonable
for both conditions to evaluate true, but in this case only the
first prints. And if you look at the bits in the two variables
you'll see that value really is bigger than huge.
Technical Details
Message-ID:
<1990Jul19.204933.18891@watmath.waterloo.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!rbutterworthReferences:
<1990Jul14.194550.14850@dinorah.wustl.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!utzoo!utgpu!watserv1!watmath!rbutterworth From: rbutterworth@watmath.waterloo.edu (Ray Butterworth) Subject: Re: What is permissable with HUGE_VAL Message-ID: <1990Jul19.204933.18891@watmath.waterloo.edu> Keywords: assignment, comparison, arithmetic on HUGE_VAL Organization: Math Faculty Computing Facility, University of Waterloo References: <1990Jul14.194550.14850@dinorah.wustl.edu> Date: Thu, 19 Jul 90 20:49:33 GMT Lines: 28