l i n u x - u s e r s - g r o u p - o f - d a v i s
L U G O D
 
Next Meeting:
November 4: Social gathering
Next Installfest:
TBD
Latest News:
Oct. 10: LUGOD Installfests coming again soon
Page last updated:
2007 Jan 26 12:02

The following is an archive of a post made to our 'vox-tech mailing list' by one of its subscribers.

Report this post as spam:

(Enter your email address)
Re: [vox-tech] location of DBL_EPSILON definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [vox-tech] location of DBL_EPSILON definition



On Fri, 2007-01-26 at 14:36 -0500, Peter Jay Salzman wrote:
> On Fri 26 Jan 07,  8:39 AM, Micah Cowan <micah@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;
}

-- 
HTH,
Micah J. Cowan
Programmer, musician, typesetting enthusiast, gamer...
http://micah.cowan.name/


_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech



LinkedIn
LUGOD Group on LinkedIn
Sign up for LUGOD event announcements
Your email address:
facebook
LUGOD Group on Facebook
'Like' LUGOD on Facebook:

Hosting provided by:
Sunset Systems
Sunset Systems offers preconfigured Linux systems, remote system administration and custom software development.

LUGOD: Linux Users' Group of Davis
PO Box 2082, Davis, CA 95617
Contact Us

LUGOD is a 501(c)7 non-profit organization
based in Davis, California
and serving the Sacramento area.
"Linux" is a trademark of Linus Torvalds.

Sponsored in part by:
O'Reilly and Associates
For numerous book donations.