>>>>> "Barton" == Barton Willis <willisb at unk.edu> writes:
Barton> What is the correct way to test for equality in the bigfloat package? There are lots of considerations, I know
Barton> (does 1.0 = 1.0b0, and ...).
Barton> But I get a Lisp error testing for equality between 0.1b0 + %i & 0.2b0.
Barton> (%i34) (x : 0.1b0, y: 0.2b0)$
Barton> Both OK
Barton> ?(%i35) :lisp(bigfloat::= (bigfloat::to $x) (bigfloat::to $y))
Barton> ?NIL
Barton> ?(%i35) :lisp(bigfloat::= (bigfloat::to $x) (bigfloat::to $x))
Barton> ?T
Barton> Oops:
Barton> ?(%i35) x : 0.1b0 + %i$
Barton> ?(%i36) :lisp(bigfloat::= (bigfloat::to $x) (bigfloat::to $y))
Barton> ?Maxima encountered a Lisp error:
Barton> ?Error in PROGN [or a callee]: No matching method for the generic-function #<compiled-closure BIGFLOAT::TWO-ARG-=>,
Barton> when called with arguments (+2.0b-1 +1.0b-1+1.0b0*%i).
That would be a bug in the bigfloat package. It seems I tried to
handle this kind of contagion, but forgot about the case of
complex-bigfloat and bigfloat. Something like the following should
work:
(defmethod two-arg-= ((a complex-bigfloat) (b bigfloat))
(and (two-arg-= (realpart a) b)
(zerop (imagpart a))))
(defmethod two-arg-= ((b bigfloat) (a complex-bigfloat))
(two-arg-= a b))