** Try to convert a value to a float. The float case is already handled ** by the macro 'tonumber'. */
| 82 | ** by the macro 'tonumber'. |
| 83 | */ |
| 84 | int luaV_tonumber_(const TValue *obj, lua_Number *n) { |
| 85 | TValue v; |
| 86 | if (ttisinteger(obj)) { |
| 87 | *n = cast_num(ivalue(obj)); |
| 88 | return 1; |
| 89 | } |
| 90 | else if (cvt2num(obj) && /* string convertible to number? */ |
| 91 | luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { |
| 92 | *n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */ |
| 93 | return 1; |
| 94 | } |
| 95 | else { |
| 96 | return 0; // conversion failed |
| 97 | } |
| 98 | } |
| 99 | |
| 100 | |
| 101 | /* |
nothing calls this directly
no test coverage detected