diff options
| -rw-r--r-- | lvm.c | 11 |
1 files changed, 7 insertions, 4 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.192 2014/03/31 19:18:24 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.193 2014/04/02 16:54:20 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 | */ |
| @@ -38,12 +38,15 @@ | |||
| 38 | 38 | ||
| 39 | 39 | ||
| 40 | /* | 40 | /* |
| 41 | ** Similar to 'tonumber', but does not attempt to convert strings. | 41 | ** Similar to 'tonumber', but does not attempt to convert strings and |
| 42 | ** Used in comparisons. | 42 | ** ensure correct precision (no extra bits). Used in comparisons. |
| 43 | */ | 43 | */ |
| 44 | static int tofloat (const TValue *obj, lua_Number *n) { | 44 | static int tofloat (const TValue *obj, lua_Number *n) { |
| 45 | if (ttisfloat(obj)) *n = fltvalue(obj); | 45 | if (ttisfloat(obj)) *n = fltvalue(obj); |
| 46 | else if (ttisinteger(obj)) *n = cast_num(ivalue(obj)); | 46 | else if (ttisinteger(obj)) { |
| 47 | volatile lua_Number x = cast_num(ivalue(obj)); /* avoid extra precision */ | ||
| 48 | *n = x; | ||
| 49 | } | ||
| 47 | else { | 50 | else { |
| 48 | *n = 0; /* to avoid warnings */ | 51 | *n = 0; /* to avoid warnings */ |
| 49 | return 0; | 52 | return 0; |
