[Info-vax] VMS Software Q1 '23 Update

Simon Clubley clubley at remove_me.eisner.decus.org-Earth.UFP
Fri Jan 27 13:44:35 EST 2023


On 2023-01-26, Arne Vajhøj <arne at vajhoej.dk> wrote:
> On 1/26/2023 12:05 PM, Single Stage to Orbit wrote:
>> On Thu, 2023-01-26 at 11:50 -0500, Dave Froble wrote:
>>>> I am of the opinion that direct testing for equality of floating
>>>> point numbers should be disallowed by every language and that
>>>> people should be forced to use an alternative where _they_ have to
>>>> specify the delta value that 2 numbers should be within before they
>>>> are considered to be equal.
>>>
>>> Well, "have to" or not, that is the only method that works ...
>> 
>> Or use rounding: IF Math.Round(x,2) = Math.Round(x,2) THEN ..

You are still directly comparing two approximations and as Arne points
out, it's not the same thing as using a delta value

>
> VB.NET?
>
> IF Math.Round(x,2) = Math.Round(y,2) THEN
>
> and:
>
> IF Math.Abs(x - y) < 0.01 THEN
>
> are not fully equivalent.
>

This is the only method that is truly robust when you are comparing
approximations instead of exact values.

(This assumes Abs() in the above example is really a floating point Abs()
instead of an integer Abs()).

Simon.

-- 
Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP
Walking destinations on a map are further away than they appear.



More information about the Info-vax mailing list