** Check whether integer 'i' is less than float 'f'. If 'i' has an ** exact representation as a float ('l_intfitsf'), compare numbers as ** floats. Otherwise, if 'f' is outside the range for integers, result ** 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 wa
| 279 | ** in false. |
| 280 | */ |
| 281 | static int LTintfloat (lua_Integer i, lua_Number f) { |
| 282 | #if defined(l_intfitsf) |
| 283 | if (!l_intfitsf(i)) { |
| 284 | if (f >= -cast_num(LUA_MININTEGER)) /* -minint == maxint + 1 */ |
| 285 | return 1; /* f >= maxint + 1 > i */ |
| 286 | else if (f > cast_num(LUA_MININTEGER)) /* minint < f <= maxint ? */ |
| 287 | return (i < cast(lua_Integer, f)); /* compare them as integers */ |
| 288 | else /* f <= minint <= i (or 'f' is NaN) --> not(i < f) */ |
| 289 | return 0; |
| 290 | } |
| 291 | #endif |
| 292 | return luai_numlt(cast_num(i), f); /* compare them as floats */ |
| 293 | } |
| 294 | |
| 295 | |
| 296 | /* |