[Cuis-dev] Negative sqrt

Gerald Klix cuis.01 at klix.ch
Wed Dec 30 04:32:03 PST 2020


Hi Juan,

please see below.

On 2020-12-29 19:47, Juan Vuletich wrote:
> Hi Gerald,
> 
> (below)
> On 12/29/2020 8:18 AM, Gerald Klix via Cuis-dev wrote:
>>
>>
>> On 2020-12-29 11:59, Gerald Klix via Cuis-dev wrote:
>>> On 2020-12-29 05:15, ken.dickey at whidbey.com wrote:
>>>> On 2020-12-28 10:46, Juan Vuletich via Cuis-dev wrote:
>>>>
>>>>> Ok. Making the existence of the Complex package easier to discover is
>>>>> a good idea. Just pushed an update, in the #defaultAction of
>>>>> NegativePowerError. Please take a look.
>>>>
>>>> Looks great to me.
>>>>
>>>> Thanks a bunch!
>>>> -KenD
>>>
>>> Sorry to report some strange behavior:
>>> Sometimes the debugger window appears alongside the menu. Sometimes 
>>> it does not, answering a NaN, if you click outside the menu or choose 
>>> not to install the Complex package. Until now I could not find any 
>>> pattern.
>>>
>>> I will test it with a clean image, soon.
>>>
>>>
>>> HTH,
>>>
>>> Gerald
>> Retested with a clean 4503 release image,
>> which I created from a clean copy of a 4426 image, installing all 
>> updates and saving it as a new release:
>>
>> '-4 sqrt' displays the menu and If I choose not to load the Complex 
>> package it pops up a debugger. If I choose proceed in the debugger,
>> it answers an instance of the NegativePowerError
>> exception.
>>
>> Choosing the same menu option with '-4.0 sqrt' directly answers a NaN.
>>
>> Juan, I presume that is not the behavior you intended. Please tell me, 
>> if I should test with a 32-bit image, that only has boxed floats.
>>
>>
>> HTH,
>>
>> Gerald
> 
> Note that if you haven't selected "Install Complex" or "Don't ask 
> again", `-4.0 sqrt` will still ask the question, the same as if the 
> receiver was an integer.
> 
> The difference is if you chose not to install Complex. And, yes, it is 
> the intended behavior.
> 
> If Complex is installed, -4 sqrt and -4.0 sqrt answer Complex. But if 
> not, -4 sqrt is an error, but -4.0 sqrt isNaN. This is because of the 
> Floating Point standard.
> 
> Floats play by their own rules, stated in the IEEE 754 standard. They 
> include special values Float infinity (so 1.0 / 0.0 = Float infinity) 
> and Float nan (so -4.0 sqrt isNaN). The other Number classes don't 
> handle these concepts, and just give errors.
OK, point taken: I agree.
> 
> Strict compliance of IEEE 754 is important. Most well known numeric 
> algorithms are guaranteed to give the expected results if the standard 
> is followed, and might break otherwise.
Well, strict IEEE 754 compliance will also require  the programming 
language to raise/signal/throw
exceptions for certain types of NaNs, if
the program/programmer requests those.

IEEE-754 2019 Clause 8.3 specifies so
called "immediate exception handling",
which, IHMO, should be implemented by signaling
Smalltalk exceptions. But this interpretation
is based on my limited understanding of the standard's concepts and may 
be wrong.
I am by no means an expert in this domain,
I only want to express my impression,
that full IEEE-754 is probably not easy to achieve. Let's be careful here!


Best Regards,

Gerald


More information about the Cuis-dev mailing list