# (EQUAL <number-of-one-type> <another-type>)

• To: DRB at MIT-MC
• Subject: (EQUAL <number-of-one-type> <another-type>)
• From: JONL at MIT-MC (Jon L White)
• Date: Sat, 24 Jun 78 04:31:00 GMT
• Cc: (BUG LISP) at MIT-MC, NIL at MIT-MC
• Original-date: 24 JUN 1978 0031-EDT

```EQUAL has classically said NO to objects of differing data types
(one minor counter to that involves treating the datatype KLUDGE4,
KLUDGE8, KLUDGE16, KLUDGE32, and so on as lists if the KLUDGEP
swithch is off).  So you would have to write your own version
of NUMERIC-EQUAL to take account the fact that you want a datum
of one numeric datatype to be equal to another kind.  E.g.,
if it is only zero that you are worried about, then hau about
(DEFUN N= (X Y)
(COND ((OR (NOT (NUMBERP X)) (NOT (NUMBERP Y))) (BARF BARF))
((ZEROP X) (ZEROP Y))
((EQUAL X Y))))
Or if you have more intricate involvement, say you want 3.0 to be
equal to 3, then hau about something like
(DEFUN N= (X Y)
(LET ((TX (TYPEP X)) (TY (TYPEP Y)))
(COND ((EQ TX TY) (COND ((MEMQ TX '(FIXNUM FLONUM)) (= X Y))
((EQUAL X Y))))
((AND (MEMQ TX '(FIXNUM FLONUM)) (MEMQ TY '(FIXNUM FLONUM)))
(COND ((EQ TX 'FLONUM) (SETQ Y (FLOAT Y)))
(T (SETQ X (FLOAT X))))
(= X Y))
((EQUAL X Y)))))
Remember, flonum equality is bitwise, not in any kind of sense of
epsilonics.  There are many schemes to try to build the epsilonics
into the system, but generally these fail, since the loser can't really
escape the effects of limited precision floating point. Systemic attempts
to hide it (thru some kind of fuzz factor) give a false sense of security.
So if the epsilonics matter in numeric equal, the loser might as well
progrma in the test himself, such as e.g.
(DEFUN F= (FX FY)
(LET ((AFX (ABS FX)) (AFY (ABS FY)))
(COND ((< AFX 1.E-30) (< AFY 1.E-30))
((< AFY 1.E-30) (< AFX 1.E-30))
((< (//\$ (ABS (-\$ FX FY)) (+\$ AFX AFY))
1.E-8))))
The two constants could of course be made into globar variables.
```