[Oberon] FPGA - DIY Dialogs

John R. Strohm strohm at airmail.net
Wed Feb 6 03:03:20 CET 2019


Floating-point numbers are not exact.

No matter how closely they may round, no matter how close they look, they 
may not be exactly equal.

You formed a number that is "close" to 123.123.  You formed another number 
that is "close" to 123.123.  When you subtracted the two, you saw the 
difference between "close" and "exact".  Your two numbers were close, but 
they were not exactly equal.  They differed by 0.0000076395, or thereabouts. 
This is probably very close to the lower error limit of your processor's 
floating-point representation.

When you multiplied the problem by two, you got "close enough" that the 
error rounded off.

I remember losing it one night, trying to explain that an error of a mile or 
so, on a problem that involved LITERALLY astronomical distances (with a 
system that was probably not too well-conditioned to begin with), was not 
bad.

I also remember a lecture in the introductory numerical methods class, 
something over forty years ago, that asked the question "What is a good 
answer?".  The example was solving two simultaneous linear equations.  One 
solution gave an error that was exactly on one of the lines, but not at the 
exact intersection.  Another gave a point that was a little way off both 
lines.  However, if you calculated the distance from the calculated solution 
to the exact solution, you found that the second method gave a "closer" 
answer.  Thirty years later, I'd say something about L-infinity norm vs. L-2 
norm.

-----Original Message----- 
From: Tomas Kral
Sent: Tuesday, February 5, 2019 3:14 PM
To: oberon at lists.inf.ethz.ch
Subject: Re: [Oberon] FPGA - DIY Dialogs

Hi,

Testing `Calc', shows something I need yet to improve about (y-x). While 
(y+x) seems alright. So are y*x, y/x.

Sanity check

123.123 Enter
123.123 Enter
-
0.0 <= good

This has a problem

123 Enter
.123 Enter
+
1.231230+E02 <= top of stack
123.123 Enter
-
7.629395-E06 <= ???

But this works

123 Enter
.123 Enter
+
1.231230+E02 <= top of stack
123.123 Enter
+
2.462460+E02 <= good
246.246 Enter
-
0.0 <= good

-- 
Tomas Kral <thomas.kral at email.cz>
--
Oberon at lists.inf.ethz.ch mailing list for ETH Oberon and related systems
https://lists.inf.ethz.ch/mailman/listinfo/oberon 


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus



More information about the Oberon mailing list