home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.unix.bsd
- Path: sparky!uunet!mcsun!Germany.EU.net!rrz.uni-koeln.de!aix370!a0045
- From: a0045@rrz.uni-koeln.de (Jochen Roderburg)
- Subject: 386BSD FP problems, or: why is 0.0 == -1.0 ??
- Message-ID: <A0045.92Sep2120530@berry.rrz.uni-koeln.de>
- Sender: news@rrz.uni-koeln.de (Usenet News System)
- Organization: Regional Computing Center, University of Cologne, F. R. Germany
- Distribution: comp
- Date: 2 Sep 92 12:05:30
- Lines: 52
-
- The C system on 386BSD seems to have some strange problems with
- floating-point constants.
-
- The following test program justs prints out a few constants:
-
- main () {
- printf ("0. %+f\n", 0. );
- printf ("0.0 %+f\n", 0.0);
- printf ("0.1 %+f\n", 0.1);
- printf ("0.5 %+f\n", 0.5);
- printf ("0.6 %+f\n", 0.6);
- printf ("1.0 %+f\n", 1.0);
- printf ("1.1 %+f\n", 1.1);
- printf ("1.5 %+f\n", 1.5);
- printf ("1.6 %+f\n", 1.6);
- }
-
- And these are the suprising results:
-
- 0. +0.000000
- 0.0 -1.000000
- 0.1 +0.000000
- 0.5 +0.000000
- 0.6 +1.000000
- 1.0 +1.000000
- 1.1 +1.000000
- 1.5 +2.000000
- 1.6 +2.000000
-
- Especially entertaining is the wonderful transformation from 0.0 to -1.0.
- You may understand that a small utility which uses a few of these constants
- brought not very useful results.
-
- The errors seem to happen already in the compiler, not during the printout.
- When you use the constants in expressions you get results that fit to the
- printout, for example 2+0.0 -> 1.0.
-
- I have observed this on PCs without mathematical coprocessor, if this is of
- any importance.
-
- Has anybody a clue what is going on here ?
-
- Jochen Roderburg
- Regional Computing Center
- University of Cologne
- Robert-Koch-Str. 10 Tel.: +49-221/470-4564
- D-5000 Koeln 41 E-Mail: Ro @ RRZ.Uni-Koeln.DE
- Germany
-
-
-
-
-