Floating point

scott andrew franco samiam at moorecad.com
Tue Sep 1 05:06:45 CEST 2020


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 at math.uni.wroc.pl>
Date: 8/31/20 7:58 pm
To: "gpc at gnu.de" <gpc at gnu.de>

On Mon, Aug 31, 2020 at 01:07:42PM -0700, scott andrew franco wrote:
 > samiam at 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 at samiam-home-pc:~/projects/pascal/pascal-p5$ gpc -o test test.pas
 > samiam at 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 at gnu.de
 https://www.g-n-u.de/mailman/listinfo/gpc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.g-n-u.de/pipermail/gpc/attachments/20200831/b7448c9e/attachment.htm>


More information about the Gpc mailing list