mirror of https://github.com/rusefi/lua.git
bug in order NaN x int (tests must ensure that NaN does not get
converted to integer)
This commit is contained in:
parent
2ecaf18138
commit
a1415c0d72
17
lvm.c
17
lvm.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lvm.c,v 2.243 2015/05/22 17:48:19 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.244 2015/06/02 19:11:24 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -262,17 +262,18 @@ static int l_strcmp (const TString *ls, const TString *rs) {
|
|||
** is trivial. Otherwise, compare them as integers. (When 'i' has no
|
||||
** float representation, either 'f' is "far away" from 'i' or 'f' has
|
||||
** no precision left for a fractional part; either way, how 'f' is
|
||||
** truncated is irrelevant.)
|
||||
** truncated is irrelevant.) When 'f' is NaN, comparisons must result
|
||||
** in false.
|
||||
*/
|
||||
static int LTintfloat (lua_Integer i, lua_Number f) {
|
||||
#if defined(l_intfitsf)
|
||||
if (!l_intfitsf(i)) {
|
||||
if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */
|
||||
return 1; /* f >= maxint + 1 > i */
|
||||
else if (f <= cast_num(LUA_MININTEGER)) /* f <= minint */
|
||||
return 0; /* f <= minint <= i --> not(i < f) */
|
||||
else /* minint < f <= maxint */
|
||||
else if (f > cast_num(LUA_MININTEGER)) /* minint < f <= maxint ? */
|
||||
return (i < cast(lua_Integer, f)); /* compare them as integers */
|
||||
else /* f <= minint <= i (or 'f' is NaN) --> not(i < f) */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return luai_numlt(cast_num(i), f); /* compare them as floats */
|
||||
|
@ -288,10 +289,10 @@ static int LEintfloat (lua_Integer i, lua_Number f) {
|
|||
if (!l_intfitsf(i)) {
|
||||
if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */
|
||||
return 1; /* f >= maxint + 1 > i */
|
||||
else if (f < cast_num(LUA_MININTEGER)) /* f < minint */
|
||||
return 0; /* f < minint <= i --> not(i <= f) */
|
||||
else /* minint <= f <= maxint */
|
||||
else if (f >= cast_num(LUA_MININTEGER)) /* minint <= f <= maxint ? */
|
||||
return (i <= cast(lua_Integer, f)); /* compare them as integers */
|
||||
else /* f < minint <= i (or 'f' is NaN) --> not(i <= f) */
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
return luai_numle(cast_num(i), f); /* compare them as floats */
|
||||
|
|
Loading…
Reference in New Issue