Waldek,
Sure, 48 bits vs 64 bits. Why didn't it truncate the mantissa on conversion to float, ie, b := maxint? I would have expected something like zeros on the right side.
Thanks,
Scott
--------- Original Message --------- Subject: Floating point From: "Waldek Hebisch" hebisch@math.uni.wroc.pl Date: 8/31/20 7:58 pm To: "gpc@gnu.de" gpc@gnu.de
On Mon, Aug 31, 2020 at 01:07:42PM -0700, scott andrew franco wrote:
samiam@samiam-home-pc:~/projects/pascal/pascal-p5$ cat test.pas program test(output); var b,c: real; begin b := maxint; c := 10.0; b := b+c; writeln(b:40:1); writeln(maxint:38); end. samiam@samiam-home-pc:~/projects/pascal/pascal-p5$ gpc -o test test.pas samiam@samiam-home-pc:~/projects/pascal/pascal-p5$ ./test 9223372036854775808.0 9223372036854775807
Note that floating point results are approximate and on 64-bit machines real accuracy is lower than integer accuracy.
-- Waldek Hebisch
_______________________________________________ Gpc mailing list Gpc@gnu.de https://www.g-n-u.de/mailman/listinfo/gpc