Re: root bug by microsoft ?

Valery Fine (fine@bnl.gov)
Wed, 18 Nov 1998 19:08:41 -0500


Dear Quan Zhu

On 18 Nov 98 at 15:06, you wrote:

>
> I was not able to post questions to the root discussion list, and I
> hope you can shed some light on the following problem:
>
> If I run the follow fairly simple test code using root:
>
> {
> Float_t x = 888.45;
> Float_t y = 888.46;
> printf("%f\n", y - x);
>
> Float_t r = x - (Int_t)x;
> printf("%f\n", r);
> }
>
> on Windows NT machine, I get the followng output:
> 0.010010
> 0.450012
>
> which is clear wrong.

I didn't understand what is wrong with the result you present.
As for me it is perfect one. You will get "exactly" the same with any
32-bits machine. Doesn't matter whether it is UNIX/Windows/VMS/MS
DOS.

> This got me ***REALLY*** worried since many
> root classes use Float_t types a lot, and I only have access to
> Windows NT machines. (However, if one changes the above code to
> Double_t, then everything appear to be ok!)

SURE, because you will double the precision of your calculations.
That why the "double" was introduced.

>

Below you will find the result I got with SunSparc machine.

root [0] Float_t x = 888.45;
root [1] Float_t y = 888.46;
root [2] printf("%f\n", y - x);
0.010010

The precision of the IEEE floating point representation is about
1.0e-7 . Apparently the result you got does fit that.

> Any ideas ?

Please, find and have a read some textbook on "Numerical
calculations with computers"

Hope this helps,

With my best regards,
Valery

=================================================================
Dr. Valeri Faine (Fine)
------------------- Phone: +1 516 344 7806
Brookhaven National Laboratory FAX : +1 516 344 4206
Bldg. 510A /STAR mailto:fine@bnl.gov
Upton, New York, 11973-5000 http://nicewww.cern.ch/~fine
USA

Dr. Valery Fine Telex : 911621 dubna su
-----------
LCTA/Joint Inst.for Nuclear Res. Phone : +7 09621 6 40 80
141980 Dubna, Moscow region Fax : +7 09621 6 51 45
Russia mailto:fine@main1.jinr.dubna.su