** Try to convert a value to a float. The float case is already handled ** by the macro 'tonumber'. */
| 70 | ** by the macro 'tonumber'. |
| 71 | */ |
| 72 | int luaV_tonumber_ (const TValue *obj, lua_Number *n) { |
| 73 | TValue v; |
| 74 | if (ttisinteger(obj)) { |
| 75 | *n = cast_num(ivalue(obj)); |
| 76 | return 1; |
| 77 | } |
| 78 | else if (cvt2num(obj) && /* string convertible to number? */ |
| 79 | luaO_str2num(svalue(obj), &v) == vslen(obj) + 1) { |
| 80 | *n = nvalue(&v); /* convert result of 'luaO_str2num' to a float */ |
| 81 | return 1; |
| 82 | } |
| 83 | else |
| 84 | return 0; /* conversion failed */ |
| 85 | } |
| 86 | |
| 87 | |
| 88 | /* |
nothing calls this directly
no test coverage detected