larcenists / larceny

Larceny Scheme implementation
Other
202 stars 32 forks source link

loss of accuracy in mixed-mode equality comparisons violates transitivity #818

Closed WillClinger closed 7 years ago

WillClinger commented 7 years ago
> (= #e1e500 +inf.0 #e1e1000)
#t
> (= #e1e500 #e1e1000)
#f
> (= #e0.99999999999999999999+1i 1.0+1.0i #e1.00000000000000000001+1i)
#t
> (= #e0.99999999999999999999+1i #e1.00000000000000000001+1i)
#f

The mixed-mode contagion matrix converts to flonums or compnums, losing accuracy that is essential for transitivity of equality comparisons.

WillClinger commented 7 years ago

There's a similar problem with other ordering predicates:

> (>= #e1e500 +inf.0 #e1e1000)
#t
> (>= #e1e500 #e1e1000)
#f
WillClinger commented 7 years ago

Fixed by changeset 2687ce636ef3f615f5b66786b0448f940e31da41

These bugs probably date all the way back to MacScheme.