diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2014-04-07 21:21:08 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2014-04-07 21:21:08 -0700 |
commit | 1491b40d10034ec35b024098941d54a1829d422a (patch) | |
tree | b26777e60ec8ce788c8d61d1c1345f6ad16dcb9f /lib.c | |
parent | 2b0b6f7cda4b2851048c9e07b9096eb7ca086e38 (diff) | |
download | txr-1491b40d10034ec35b024098941d54a1829d422a.tar.gz txr-1491b40d10034ec35b024098941d54a1829d422a.tar.bz2 txr-1491b40d10034ec35b024098941d54a1829d422a.zip |
* 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).
Diffstat (limited to 'lib.c')
-rw-r--r-- | lib.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -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) |