On Wed, Apr 7, 2021 at 9:16 AM Ralph Mellor <ralphdjmel...@gmail.com> wrote:
[snip]

>
> Aiui this is correct (and to me intuitive) behaviour described here:
>
> https://docs.raku.org/language/numerics#Numeric_infectiousness
>
>
An overly simplified rule is being specified, without  any mention of the
underlying reasoning, to deal with situations that are anything but
"simple".
The documentation does, of course, explain correctly what raku does.
But I find the "logic" of what is going on here to be confusing.

C:\_32>raku -e "say 1.8446744073709552e+19 == 18446744073709551615"
True

The LHS is a Num that exactly represents the base 2 integer
value1000000000000000000000000000000000000000000000000000000000000000.
The RHS is an Int that exactly represents the base 2 integer value
111111111111111111111111111111111111111111111111111111111111111.
I am surprised that raku perpetuates the dumb perl5/C behaviour of
asserting that those 2 values are equivalent.

When you throw in:

C:\_32>raku -e "say Similar things happen when Num and Rat/FatRat values
are intermingled. == 18446744073709551614"
True

C:\_32>raku -e "say 18446744073709551615  == 18446744073709551614"
False

we're left with the confusion of knowing that we have an instance of A == B
&& A == C, but B != C.
(A similar situation occurs when Num and Rat/FatRat values are
intermingled.)

Contrast that with the consistency of python3:

$ python3 -c "print(1.8446744073709552e+19 == 18446744073709551615)"
False

$ python3 -c "print(1.8446744073709552e+19 == 18446744073709551614)"
False

$ python3 -c "print (18446744073709551615 == 18446744073709551614)"
False

I'm not saying that raku is any worse than perl5 or C in this respect (it
isn't), but I am saying  that I much prefer the way that python3 deals with
the mixing of numeric types.

Of course, my preferences count for nothing at all.
Python, perl5, raku, C, the GMP and MPFR libraries all document what they
are doing - and all that matters is that they adhere to their respective
documentations.
All I have to do is to be aware of the differences, and code accordingly.

Cheers,
Rob

Reply via email to