[Cuis-dev] closeTo: number?

Andres Valloud ten at smallinteger.com
Thu Aug 1 12:02:05 PDT 2024


Yes, defining something like "closeTo:" with e.g. a hard coded tolerance 
of 0.0001 does not make sense.  What does "close" mean?  To whom?  When? 
  Who knows.

What does make sense is to specify the number of ulps of imprecision 
you're willing to tolerate, for the particular application in question. 
Sometimes that tolerance is literally 0 ulps, and any positive number of 
ulps is just bad.  Some examples for the sake of clarity...

	2.0 * 2.0 must be 4.0 exactly
	1.0 timesTwoPower: -1500 must be 0.0 exactly
	any finite value plus its negation must be 0.0 exactly

It is also easy to be led astray.  For example,

	17 / 20 = 0.85

is a mathematical impossibility, even if right now the system tries to 
be helpful by answering true.

On 8/1/24 11:39 AM, Martin McClure via Cuis-dev wrote:
> I quote Juan's reply below. which basically says "we should not do it in 
> the base image." And I completely agree. Although there are situations 
> where this kind of test is appropriate, I've seen too many cases where 
> tests written to accept approximate answers hide legitimate bugs.
> 
> I realize that this does make porting more difficult, and you have my 
> sympathies for that.
> 
> Regards,
> -Martin
> 
> On 7/9/24 07:31, Juan Vuletich via Cuis-dev wrote:
>> On 7/8/2024 10:45 PM, Mark Volkmann via Cuis-dev wrote:
>>> Were these instance methods in the `TestCase` class removed recently?
>>>
>>> assert:isCloseTo:
>>> assert:isCloseTo:withinPrecision:
>>> assert:isNotCloseTo:
>>> assert:isNotCloseTo:withinPrecision:
>>>
>>> I see them in the file Cuis7.0.sources, but I don't see them in a 
>>> System Browser when the TestCase class is selected.
>>>
>>> -- 
>>> R. Mark Volkmann
>>> Object Computing, Inc.
>>
>> Yes.
>>
>> There is no general and correct way to provide those kinds of 
>> services. Anybody writing tests for numerical code should decide how 
>> to test for correct results in the context of what they are testing.
> 
> 
> On 8/1/24 06:35, Hilaire Fernandes via Cuis-dev wrote:
>> Hi,
>>
>> I am porting some package usint it in the test.
>>
>> How should we do it in the stock image? I don't want to add an 
>> extension in the package.
>>
>> I think we discussed it some weeks ago but I can't search the mailing 
>> list.
>>
>> Thanks
>>
> 
> 


More information about the Cuis-dev mailing list