Hi,
I have found out that NaN is not supported by gcc under FreeBSD. But FreeBSD
is supposed to support IEEE float point standard 754, right?
thanks,
Thomas
thanks,
Thomas
> thanks,
> Thomas
$ gcc nan.c -onanQuote:> I have found out that NaN is not supported by gcc under FreeBSD. But FreeBSD
> is supposed to support IEEE float point standard 754, right?
int
main(void)
{
unsigned long long x = 0xFFFFFFFFFFFFFFFFU;
double *d = (double *)&x;
printf("*d = %f\n",*d);
if (isnan(*d))
{
printf("*d is not a number!\n");
}
else
{
printf("*d IS a number!\n");
}
return 0;
$ gcc --versionQuote:}
--
http://www.naisbodo.com/
int main()
{
double z = 1.0/0.0;
double x = z/z;
fprintf(stdout, "Hello\n");
fflush(stdout);
fprintf(stdout, "z %e\n", 1.0/(1.0 - 1.0));
fflush(stdout);
fprintf(stdout, "Hello\n");
fflush(stdout);
fprintf(stdout, "x %e\n", x);
fflush(stdout);
return 0;
====================================================================Quote:}
I guess I should turn on some option or configuration under FreeBSD. Could
someone help me?
Thanks,
Thomas
> > Hi,
> > I have found out that NaN is not supported by gcc under FreeBSD. But
FreeBSD
> > is supposed to support IEEE float point standard 754, right?
> > thanks,
> > Thomas
You forgot to tell us which version of FreeBSD you are using and ifQuote:> #include <stdio.h>
> int main()
> {
> double z = 1.0/0.0;
> double x = z/z;
[...]
> return 0;
> }
You have hit a known problem (at least to me, one of your friendly gccQuote:> I guess I should turn on some option or configuration under FreeBSD. Could
> someone help me?
With your code (in these environments), I see:
On FreeBSD/alpha 4.2-BETA with system compiler:
; /usr/bin/gcc t.c
; ./a.out
floating point exception--core dumped
; /usr/bin/gcc -mieee t.c
; ./a.out
Hello
z Inf
Hello
x NaN
On FreeBSD/alpha 4.2-BETA with 20001201 snapshot from GNU CVS archive:
; /usr/local/beta-gcc/bin/gcc t.c
; ./a.out
floating point exception--core dumped
; /usr/local/beta-gcc/bin/gcc -mieee t.c
; ./a.out
Hello
z Inf
Hello
x NaN
On FreeBSD/i386 3.4 with system compiler, 2.95.2, and 20001129 snapshot:
floating point exception--core dumped
[I could find no obvious option to make this work without a core dump.]
On FreeBSD/i386 4.2-RELEASE with system compiler and 20001120 snapshot:
Hello
z Inf
Hello
x NaN
Regards,
Loren
--
Loren J. Rittle
Staff Software Engineer, Distributed Object Technology Lab
Networks and Infrastructure Research Lab (IL02/2240), Motorola Labs
This is correct - you're dividing by zero, which according to IEEE 754 is aQuote:> Under WIN32, I get:
> Hello
> z Inf
> Hello
> x NaN
> But under FreeBSD, I get:
> Floating exception(core dumped)
I don't have a 3.x box to try this on, but have you tried compiling your codeQuote:> I guess I should turn on some option or configuration under FreeBSD. Could
> someone help me?
See the "IEEE STANDARD 754 Floating-Point Arithmetic" section in math(3m) for
more info on this.
Nick
Hello! Can some kind soul please send me the ieee floating
point (4-byte) format? (as in bits, meaning, etc -- mantissa,
sign bit, implied leading bit presence, etc). Or, please tell
me where to find a doc on in on the net.
I'm trying to read vms four-byte floats with an sgi machine
(because vms-style floats is, apparently, what the robot I'm
talking to uses). Of course, better yet would be code
which converts vms -> ieee and ieee -> vms.
Thank you!
Dr. Chip
--
Charles E Campbell, Jr, PhD -[o]-
Intelligent Robotics Laboratory / [:] \ The Next Generation
Goddard Space Flight Center || || In Robotics
2. HiTech notebook with Solaris
3. VM/CMS float conversion to IEEE float for AIX?
4. Anybody has a Matrox MGA-PRO running?
5. does freeBSD support IEEE (firewire) DISK drives?
6. which distro
7. ANSI/IEEE double-precision floating-point arithmetic?
10. Are IEEE floats platform independent?
11. Linux floating point/IEEE Std.745-1985 compliancy
12. IEEE Floating Point significant digits
13. egcs compatibility with IEEE floating point standard