MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / luaV_tonumber_

Function luaV_tonumber_

src/Chain/libraries/glua/lvm.cpp:84–98  ·  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

82** by the macro 'tonumber'.
83*/
84int 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/*

Callers

nothing calls this directly

Calls 1

luaO_str2numFunction · 0.85

Tested by

no test coverage detected