AltME: REBOL3

Messages

Ladislav
Ladislav
"Is there not an argument to retain the current behaviour for equal? but change strict-equal? to be transitive?" - hmm, I guess that I know what you wanted to ask. Given a transitive approximate-equal? (AE?) function, we can easily define a transitive approximate-lesser-or-equal? (ALE?) function. The definition would be as follows: ALE?: func [x [decimal!] y [decimal!]] [((lesser? x y) or (ae? x y))]. We could also define approximate-lesser? (AL?) function: AL?: func [x [decimal!] y [decimal!]] [(lesser? x y) and not (ae? x y)], etc.
Does that answer your question, Peter?

PeterWood
Perhaps Ladislav. What I am asking is whether it would be good to retain the current behaviour for equal?. I'm sure that Carl implemented it that way with good reason. I realise that this may still be the result with the transitive approximate-equal? (but Im not sure).
I feel that these two examples of the current equal? behaviour should be retained (if possible):
>> equal? 0.49999999999999994 0.5
== true
>> equal? 0.1 + 0.1 + 0.1 0.3
== true
but that this behaviour should be changed:
>> strict-equal? 0.49999999999999994 0.5
== true -->> false
>> strict-equal? 0.1 + 0.1 + 0.1 0.3
== true -->> false
>> strict-equal? 0.1 + 0.1 + 0.1 0.3
== true
DideC
It's what I though too.
Same behaviour for '= and '== of course.
But it does not answer to the 'lesser-or-equal? and 'greater-or-equal? transitivity question.
PeterWood
I left an extra line in my posting :-(
What I am suggesting that it would be good for equal? to use Ladislav's transitive approximate-equal? but strict-equal? should check that the values are actually equal. So that the future behaviour would be
>> equal? 0.1 + 0.1 + 0.1 0.3
== true
>> strict-equal? 0.1 + 0.1 + 0.1 0.3
== false
I suppose same? could provide the actual check that the values are actually equal but it doesn't seem to in Rebol2
>> same? 0.1 + 0.1 + 0.1 3
== false
>> same? 0.49999999999999994 0.5
== true
Typo:
>>  same? 0.1 + 0.1 + 0.1 0.3
== true
Ladislav
Hi, I corrected the AE? function at https://github.com/rebol/rebol-issues/issues/2259 (there were some bugs) and improved comments.
PeterWood
I see that same? works as I expected in Rebol 3:
>> same? 0.49999999999999994 0.5
== false
>> same? 0.1 + 0.1 + 0.1 0.3
== false
Ladislav
Yes, Peter
PeterWood
So my thought that strict-equal? should check for the values being the same is probably not necessary.
Ladislav
examples:
>> ae? 0.49999999999999994 0.5
== true
>> ae? 0.1 + 0.1 + 0.1 0.3
== true
However, AE? is transitive, and (while only exceptionally), sometimes you get FALSE from AE? A B even when A and B differ only by one ULP. This is inevitable for a transitive relation.
(I should have said: this is inevitable for a nontrivial transitive relation)
PeterWood
That seems very reasonable.
Ladislav
At present, there is only one difference between SAME? and STRICT-EQUAL? for decimals in Rebol3. It is this one:
>> strict-equal? 0.0 -0.0
== true
>> same? 0.0 -0.0
== false
The difference is caused by the fact that 0.0 and -0.0 have different binary representations.
>> to binary! 0.0
== #{0000000000000000}
>> to binary! -0.0
== #{8000000000000000}

Last message posted 161 weeks ago.