summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--lib.c18
2 files changed, 19 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index c07f4669..b9085cec 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2014-04-07 Kaz Kylheku <kaz@kylheku.com>
+
+ * lib.c (eql): Bugfix: not handling floating-point types!
+ Two objects which are equal floating-point values must be considered
+ eql even if they are distinct objects (not eq).
+
2014-04-04 Kaz Kylheku <kaz@kylheku.com>
Version 88
diff --git a/lib.c b/lib.c
index e3390559..5bf37ed4 100644
--- a/lib.c
+++ b/lib.c
@@ -1170,12 +1170,20 @@ cnum c_num(val num);
val eql(val left, val right)
{
- /* eql is same as eq for now, but when we get bignums,
- eql will compare different bignum objects which are
- the same number as equal. */
- if (type(left) == BGNUM)
+ /* eql is the same as eq except that numbers
+ are compared by value. This means that bignum and
+ floatinmg point objects which are distinct are
+ treated through the equal function. */
+ if (left == right)
+ return t;
+
+ switch (type(left)) {
+ case BGNUM:
+ case FLNUM:
return equal(left, right);
- return eq(left, right);
+ default:
+ return nil;
+ }
}
val equal(val left, val right)