home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: gnu.gcc.bug
- Path: sparky!uunet!cis.ohio-state.edu!moonlite.CAlvacom.FR!local
- From: local@moonlite.CAlvacom.FR (Local Unix modifications)
- Subject: Floating point problems with gcc 2.3.1 on ISC Unix
- Message-ID: <9211210929.AA15389@moonlite.calvacom.fr>
- Sender: gnulists@ai.mit.edu
- Reply-To: JH10@calvacom.fr (John Hughes)
- Organization: GNUs Not Usenet
- Distribution: gnu
- Date: Sat, 21 Nov 1992 09:29:26 GMT
- Approved: bug-gcc@prep.ai.mit.edu
- Lines: 41
-
- As I reported earlier the following little program, when compiled with
- gcc 2.3.1 gives a bad answer when run on Interactive Unix 2.2. It
- works when compiled with gcc 2.1. I can now also report that it works
- (even when compiled with gcc 2.3.1) when run on a machine with a FPU.
- That is to say the problem is caused by a bug in Interactive's 80387
- emulator that is used when no physical 80387 is present. (Or is it
- ATT's emulator? In other words will the problem affect non ISC
- system V.3.2's on 386's ? How about System V.4 ?
-
- The program:
-
- ------------------------------------------------
-
- #include <stdio.h>
-
-
- void Store (float a, float *b) { *b=a; }
- float Sum (float a, float b) {float r; Store(a+b, &r); return (r); }
- float Diff (float a, float b){float r; Store(a-b, &r); return (r); }
- float Mul (float a, float b) {float r; Store(a*b, &r); return (r); }
-
-
- int main () {
- volatile int digits = 0;
- volatile float b = 1.0;
- volatile float base = 2;
-
- do {
- digits++;
- b = Mul (b, base);
- }
- while (Diff (Diff (Sum (b, 1.0), b), 1.0) == 0.0);
-
- printf ("Digits = %d\n", digits);
-
- return 0;
- }
-
- --
- John Hughes, RCI CalvaCom, Paris, France
-
-