FP Math Problem

[ Available lists | Index of freebsd-hackers | Month of Mar 1999 | Week of 4 Mar 1999 | Raw email | View thread | Wrap long lines | Reply | Tag ]
From
Crist J. Clark <cjc@cc942873-a.ewndsr1.nj.home.com>
Date
4 Mar 1999 14:39:33
Subject
FP Math Problem
Message-ID
199903042248.RAA08114@cc942873-a.ewndsr1.nj.home.com

Replies

[ Hide this part ]
I am trying to figure out why the following program produces a
floating point exception and core dumps.

#include <stdio.h>
#include <floatingpoint.h>
#include <float.h>

int main()
{

double a = 1e200;
double b;

printf("fpgetmask: %o\n",fpgetmask());

printf("a: %e\n",a);

b = a*a;

printf("isinf: %d\n",isinf(b));

printf("isnan: %d\n",isnan(b));

printf("b > DBL_MAX: %d\n",b>DBL_MAX);

printf("b: %e\n",b);

return 0;
}

My output is,

[112:~/tmp] ./dtest
fpgetmask: 15
a: 1.000000e+200
isinf: 0
isnan: 0
Floating exception (core dumped)

I started with this on -questions and (although the thread got
sidetracked by a bad test program I presented at the beginning) other
FreeBSDers have not reproduced the error, but get what I would expect,

% ./dtest
fpgetmask: 15
a: 1.000000e+200
isinf: 1
isnan: 0
b > DBL_MAX: 1
b: inf

However, I get the FPE and core dump on my three FreeBSD machines
(different hardware on each). All are,

FreeBSD pc252.scitec.com 2.2.8-STABLE FreeBSD 2.2.8-STABLE #0: Mon Mar 1 14:25:39 EST 1999

Give or take a few days on the CVSup. (All were recently built to
2.2.8-S from 2.2.7-R.)

It has been suggested I have somehow mucked up my floating point,
but I do not know where to start and -questions did not
produce many leads.

Thanks for any help. More details can be provided; I would not know
where to start.
--
Crist J. Clark cjclark@home.com


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Elapsed time: 0.120 seconds