From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Buck To: slouken@devolution.com (Sam Lantinga) Cc: egcs@egcs.cygnus.com Subject: Re: Rounding errors using doubles? Date: Thu, 18 Mar 1999 16:12:00 -0000 Message-id: <199903190011.QAA11085@atrus.synopsys.com> In-reply-to: < E10NmPs-0005mx-00@roboto.devolution.com >; from "Sam Lantinga" at Mar 18, 99 3:41 pm References: X-SW-Source: 1999-03/msg00631.html > On a Pentium II, the following code gives an incorrect result when using > doubles, but a correct result when using floats: Take it to a beginner's programming group. (Hint: .86 can't be represented exactly in floating point, the nearest IEEE float is a hair above .86, the nearest IEEE double is a hair below .86; in C, conversion from float or double to integer truncates, it does not round). > This is VERY bad for our software. Any compiler will be very bad for your software, until you learn how to use floating point. From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joe Buck To: slouken@devolution.com (Sam Lantinga) Cc: egcs@egcs.cygnus.com Subject: Re: Rounding errors using doubles? Date: Wed, 31 Mar 1999 23:46:00 -0000 Message-ID: <199903190011.QAA11085@atrus.synopsys.com> References: X-SW-Source: 1999-03n/msg00636.html Message-ID: <19990331234600.ebxIch_YmDJO1IpcOZKjwN6r1R7-xjg5E3R09udd-OA@z> > On a Pentium II, the following code gives an incorrect result when using > doubles, but a correct result when using floats: Take it to a beginner's programming group. (Hint: .86 can't be represented exactly in floating point, the nearest IEEE float is a hair above .86, the nearest IEEE double is a hair below .86; in C, conversion from float or double to integer truncates, it does not round). > This is VERY bad for our software. Any compiler will be very bad for your software, until you learn how to use floating point.