MCPcopy Create free account
hub / github.com/DFHack/dfhack / luaV_tonumber_

Function luaV_tonumber_

depends/lua/src/lvm.c:72–85  ·  view source on GitHub ↗

** Try to convert a value to a float. The float case is already handled ** by the macro 'tonumber'. */

Source from the content-addressed store, hash-verified

70** by the macro 'tonumber'.
71*/
72int 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/*

Callers

nothing calls this directly

Calls 1

luaO_str2numFunction · 0.85

Tested by

no test coverage detected