comparison src/fns.c @ 3379:68f28e378f50

(internal_equal): Don't let ints be equal to floats.
author Richard M. Stallman <rms@gnu.org>
date Tue, 01 Jun 1993 03:38:24 +0000
parents b2e9e2ae0e10
children 71541ea16adf
comparison
equal deleted inserted replaced
3378:cb9eb3e46e2c 3379:68f28e378f50
818 DEFUN ("equal", Fequal, Sequal, 2, 2, 0, 818 DEFUN ("equal", Fequal, Sequal, 2, 2, 0,
819 "T if two Lisp objects have similar structure and contents.\n\ 819 "T if two Lisp objects have similar structure and contents.\n\
820 They must have the same data type.\n\ 820 They must have the same data type.\n\
821 Conses are compared by comparing the cars and the cdrs.\n\ 821 Conses are compared by comparing the cars and the cdrs.\n\
822 Vectors and strings are compared element by element.\n\ 822 Vectors and strings are compared element by element.\n\
823 Numbers are compared by value. Symbols must match exactly.") 823 Numbers are compared by value, but integers cannot equal floats.\n\
824 (Use `=' if you want integers and floats to be able to be equal.)\n\
825 Symbols must match exactly.")
824 (o1, o2) 826 (o1, o2)
825 register Lisp_Object o1, o2; 827 register Lisp_Object o1, o2;
826 { 828 {
827 return internal_equal (o1, o2, 0); 829 return internal_equal (o1, o2, 0);
828 } 830 }
836 error ("Stack overflow in equal"); 838 error ("Stack overflow in equal");
837 do_cdr: 839 do_cdr:
838 QUIT; 840 QUIT;
839 if (EQ (o1, o2)) return Qt; 841 if (EQ (o1, o2)) return Qt;
840 #ifdef LISP_FLOAT_TYPE 842 #ifdef LISP_FLOAT_TYPE
841 if (NUMBERP (o1) && NUMBERP (o2)) 843 if (FLOATP (o1) && FLOATP (o2))
842 { 844 return (extract_float (o1) == extract_float (o2)) ? Qt : Qnil;
843 return (extract_float (o1) == extract_float (o2)) ? Qt : Qnil;
844 }
845 #endif 845 #endif
846 if (XTYPE (o1) != XTYPE (o2)) return Qnil; 846 if (XTYPE (o1) != XTYPE (o2)) return Qnil;
847 if (XTYPE (o1) == Lisp_Cons 847 if (XTYPE (o1) == Lisp_Cons
848 || XTYPE (o1) == Lisp_Overlay) 848 || XTYPE (o1) == Lisp_Overlay)
849 { 849 {