[fpc-pascal] float calculates rubbish

Marc Santhoff M.Santhoff at t-online.de
Sun Mar 6 22:42:39 CET 2005


Hi,

i was confused and defined some real values as float in a GTK program.
GDK (glib.pp) defines float as single. Look what happened:

program testlongfloat;
uses sysutils, glib;
const
	c1: float = 1109081270;
	c2: float = 1109081270 / 2;

BEGIN
	writeln(inttostr(trunc((c1))));
	writeln(floattostrf(c1,fffixed,8,2));
	writeln(inttostr(trunc((c2))));
	writeln(floattostrf(c2,fffixed,8,2));
END.

$ ./testlongfloat
1109081216
1109081216.00
554540608
554540608.00

Am I producing a value overflow here or what's happening? The whole
thing is running on i386 with fpc 1.9.4.

I do not know if single is equivalent to extended on i386 or not.

Next time I'll use an appropriate type declaration from the start, btw.
;)

Thanks,
Marc






More information about the fpc-pascal mailing list