RE: Floating point

"scott andrew franco" <[email protected]> Mon, 31 Aug 2020 20:06:45 -0700
Newsgroups gmane.comp.compilers.gpc
Message-ID <20200831200645.6c61c97e98fe7bb02193b2d6dca4a85a.22eec1f839.mailapi@email15.godaddy.com>
--===============3327379751819154212==
Content-Type: multipart/alternative;
 boundary="=_c42a3c4d08dc8ad7d07f8b8e39d3b8be"

--=_c42a3c4d08dc8ad7d07f8b8e39d3b8be
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
 charset=utf-8

Waldek,
=20
Sure, 48 bits vs 64 bits. Why didn't it truncate the mantissa on conversion=
 to float, ie, b :=3D maxint?
I would have expected something like zeros on the right side.
=20
Thanks,
=20
Scott
=20
--------- Original Message --------- Subject: Floating point
From: "Waldek Hebisch" <[email protected]>
Date: 8/31/20 7:58 pm
To: "[email protected]" <[email protected]>

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 :=3D maxint;
 > c :=3D 10.0;
 > b :=3D 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
=20
 Note that floating point results are approximate and on
 64-bit machines real accuracy is lower than integer
 accuracy.
=20
 --=20
 Waldek Hebisch
=20
 _______________________________________________
 Gpc mailing list
 [email protected]
 https://www.g-n-u.de/mailman/listinfo/gpc

--=_c42a3c4d08dc8ad7d07f8b8e39d3b8be
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
 charset=utf-8

<div>Waldek,</div>
<div>&nbsp;</div>
<div>Sure, 48 bits vs 64 bits.&nbsp;Why didn't it truncate the mantissa on =
conversion to float, ie, b :=3D maxint?</div>
<div>I would have expected something like zeros on the right side.</div>
<div>&nbsp;</div>
<div>Thanks,</div>
<div>&nbsp;</div>
<div>Scott</div>
<div>&nbsp;</div>
<blockquote class=3D"threadBlockQuote" style=3D"border-left: 2px solid #C2C=
2C2; padding-left: 3px; margin-left: 4px;">--------- Original Message -----=
----
<div>Subject: Floating point<br />From: "Waldek Hebisch" &lt;hebisch@math=
=2Euni.wroc.pl&gt;<br />Date: 8/31/20 7:58 pm<br />To: "[email protected]" &lt;gpc=
@gnu.de&gt;<br /><br />On Mon, Aug 31, 2020 at 01:07:42PM -0700, scott andr=
ew franco wrote:<br /> &gt; samiam@samiam-home-pc:~/projects/pascal/pascal-=
p5$ cat test.pas<br /> &gt; program test(output);<br /> &gt; var b,c: real;=
<br /> &gt; begin<br /> &gt; b :=3D maxint;<br /> &gt; c :=3D 10.0;<br /> &=
gt; b :=3D b+c;<br /> &gt; writeln(b:40:1);<br /> &gt; writeln(maxint:38);<=
br /> &gt; end.<br /> &gt; samiam@samiam-home-pc:~/projects/pascal/pascal-p=
5$ gpc -o test test.pas<br /> &gt; samiam@samiam-home-pc:~/projects/pascal/=
pascal-p5$ ./test<br /> &gt; 9223372036854775808.0<br /> &gt; 9223372036854=
775807<br /> <br /> Note that floating point results are approximate and on=
<br /> 64-bit machines real accuracy is lower than integer<br /> accuracy=
=2E<br /> <br /> -- <br /> Waldek Hebisch<br /> <br /> ____________________=
___________________________<br /> Gpc mailing list<br /> [email protected]<br /> h=
ttps://www.g-n-u.de/mailman/listinfo/gpc</div>
</blockquote>

--=_c42a3c4d08dc8ad7d07f8b8e39d3b8be--


--===============3327379751819154212==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Gpc mailing list
[email protected]
https://www.g-n-u.de/mailman/listinfo/gpc

--===============3327379751819154212==--