🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

1 total messages Started by Local Unix modifications Sat, 21 Nov 1992 09:29
Floating point problems with gcc 2.3.1 on ISC Unix
#1452
Author: Local Unix modifications
Date: Sat, 21 Nov 1992 09:29
40 lines
1662 bytes
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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads