[vox-tech] location of DBL_EPSILON definition

Peter Jay Salzman p at dirac.org
Fri Jan 26 12:03:12 PST 2007


On Fri 26 Jan 07, 11:46 AM, Micah Cowan <micah at cowan.name> said:
> On Fri, 2007-01-26 at 14:36 -0500, Peter Jay Salzman wrote:
> > On Fri 26 Jan 07,  8:39 AM, Micah Cowan <micah at cowan.name> said:
> 
> > > My float.h simply defines DBL_EPSILON to __DBL_EPSILON__. There does not
> > > appear to be an inclusion of some other file, or a definition of
> > > __DBL_EPSILON__. So the answer to your question would seem: compiler
> > > magic. :)
> >  
> > This is very unfortunate.  I liked having one file to look at for all my
> > float constant curiosity.
> 
> In that case, you could try one of the following:
> 
>      1. Write a simple C program that prints out, to the maximum useful
>         precision, the values you're interested in. Actually, chances
>         are you could use C preprocessing stringization to get /exactly/
>         the values used.
>      2. The preprocessor seems to translate the magic __DBL_EPSILON__
>         (rather than the compiler proper); therefore, running gcc -E on
>         a file like:
> 
> #include <float.h>
> DBL_EPSILON
> 
> gives (for me):
> 
> # 1 "test.c"
> # 1 "<built-in>"
> # 1 "<command line>"
> # 1 "test.c"
> # 1 "/usr/lib/gcc/i486-linux-gnu/4.1.2/include/float.h" 1 3 4
> # 2 "test.c" 2
> 2.2204460492503131e-16
> 
> --------
> 
> ...for method #1, above, you could do something like:
> 
> #include <float.h>
> #include <stdio.h>
> 
> #define STR2(x) #x
> #define STR(x) STR2(x)
> 
> int main(void) {
>     printf("DBL_EPSILON: %s\n", STR(DBL_EPSILON));
>     /* ... etc ... */
>     return 0;
> }
 

I understand all that, in fact I used option #1 two nights ago (option #2 is
pretty clever, btw).  But it still doesn't change fact:

This is very unfortunate.  I liked having one file to look at for all my
float constant curiosity.

I'll even add:

It's unfortunate that I have to do *anything* other than to type the words
"less <file>".  :(

Thanks,
Peter

-- 
How VBA rounds a number depends on the number's internal representation.
You cannot always predict how it will round when the rounding digit is 5.
If you want a rounding function that rounds according to predictable rules,
you should write your own.
              -- MSDN, on Microsoft VBA's "stochastic" rounding function

Peter Jay Salzman, email: p at dirac.org web: http://www.dirac.org/p    
PGP Fingerprint: B9F1 6CF3 47C4 7CD8 D33E  70A9 A3B9 1945 67EA 951D


More information about the vox-tech mailing list