aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-04-29 15:27:16 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-04-29 15:27:16 -0300
commit04ba6ea83be2408ddc287db7fe69393bd31d171b (patch)
tree4125274a892a17fe180315cb1c83ce0052bd22ec
parenta1935b9cba4ba4619028e2257e8367f054ce7af8 (diff)
downloadlua-04ba6ea83be2408ddc287db7fe69393bd31d171b.tar.gz
lua-04ba6ea83be2408ddc287db7fe69393bd31d171b.tar.bz2
lua-04ba6ea83be2408ddc287db7fe69393bd31d171b.zip
new semantics for equality int-float
-rw-r--r--lvm.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/lvm.c b/lvm.c
index 1025e885..ed32455c 100644
--- a/lvm.c
+++ b/lvm.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lvm.c,v 2.238 2015/03/30 15:45:01 roberto Exp roberto $ 2** $Id: lvm.c,v 2.239 2015/04/10 17:56:25 roberto Exp roberto $
3** Lua virtual machine 3** Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -301,10 +301,8 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
301 if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER) 301 if (ttnov(t1) != ttnov(t2) || ttnov(t1) != LUA_TNUMBER)
302 return 0; /* only numbers can be equal with different variants */ 302 return 0; /* only numbers can be equal with different variants */
303 else { /* two numbers with different variants */ 303 else { /* two numbers with different variants */
304 lua_Number n1, n2; /* compare them as floats */ 304 lua_Integer i1, i2; /* compare them as integers */
305 lua_assert(ttisnumber(t1) && ttisnumber(t2)); 305 return (tointeger(t1, &i1) && tointeger(t2, &i2) && i1 == i2);
306 cast_void(tofloat(t1, &n1)); cast_void(tofloat(t2, &n2));
307 return luai_numeq(n1, n2);
308 } 306 }
309 } 307 }
310 /* values have same type and same variant */ 308 /* values have same type and same variant */