From owner-freebsd-questions Tue Mar 2 8:54: 6 1999 Delivered-To: freebsd-questions@freebsd.org Received: from cc942873-a.ewndsr1.nj.home.com (cc942873-a.ewndsr1.nj.home.com [24.2.89.207]) by hub.freebsd.org (Postfix) with ESMTP id 0FD0D14D86 for ; Tue, 2 Mar 1999 08:54:03 -0800 (PST) (envelope-from cjc@cc942873-a.ewndsr1.nj.home.com) Received: (from cjc@localhost) by cc942873-a.ewndsr1.nj.home.com (8.9.3/8.8.8) id MAA02135 for freebsd-questions@FreeBSD.ORG; Tue, 2 Mar 1999 12:03:04 -0500 (EST) (envelope-from cjc) From: "Crist J. Clark" Message-Id: <199903021703.MAA02135@cc942873-a.ewndsr1.nj.home.com> Subject: FP Math To: freebsd-questions@FreeBSD.ORG (FreeBSD Questions) Date: Tue, 2 Mar 1999 12:03:04 -0500 (EST) Reply-To: cjclark@home.com X-Mailer: ELM [version 2.4ME+ PL40 (25)] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG I have been having some trouble with floating point operations, namely the dreaded, Floating exception (core dumped) Having a look at 'man math' only really served to confuse me more. The manpage lays out information about two libraries, DEC VAX-11 D_floating-point and IEEE STANDARD 754 Floating-Point Arithmetic. However, no where does the manpage really come clean and admit what we are using. I _think_ I am using the IEEE Standard, but have been getting weird results. See below for an example. I think the problems are related to float-double issues. Why does the manpage inform me about both? Does it mean I can somehow select one or the other? If I can, how do I do it? Thanks. Example: Here are two quick C program that I think show why I am confused. The first produces an exception and core dumps (for me anyway). In this one, I have set floats to values outside of their range. It dumps at the point marked, --- C Code --- #include int main() { float a = -1.0e-41; float b = -1.0e-41; float c = 1.0e-41; float d; printf("%g\n%g\n",a,c); /* This outputs values a and b different than those set */ d = a/b; /* This works */ printf("%g\n",d); /* Still OK */ d /= c; /* FP exception, core dump */ printf("%g\n",d); return 0; } --- End C Code --- Now the problem printing I could understand. I have set the floats outside of their range. However, if I change the initial values slightly, --- C Code --- #include int main() { float a = -1.0e41; float b = -1.0e-41; float c = 1.0e-41; float d; printf("%g\n%g\n",a,c); /* This gets a as it should be now */ d = a/b; /* This works */ printf("%g\n",d); /* Still OK */ d /= c; /* now this works! */ printf("%g\n",d); return 0; } --- End C Code --- Could someone explain this? [Should I send this to -hackers instead?] -- Crist J. Clark cjclark@home.com To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message