MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaV_flttointeger

Function luaV_flttointeger

lib/lua/src/lvm.c:133–141  ·  view source on GitHub ↗

** try to convert a float to an integer, rounding according to 'mode'. */

Source from the content-addressed store, hash-verified

131** try to convert a float to an integer, rounding according to 'mode'.
132*/
133int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode) {
134 lua_Number f = l_floor(n);
135 if (n != f) { /* not an integral value? */
136 if (mode == F2Ieq) return 0; /* fails if mode demands integral value */
137 else if (mode == F2Iceil) /* needs ceil? */
138 f += 1; /* convert floor to ceil (remember: n != f) */
139 }
140 return lua_numbertointeger(f, p);
141}
142
143
144/*

Callers 10

luaV_tointegernsFunction · 0.85
LTintfloatFunction · 0.85
LEintfloatFunction · 0.85
LTfloatintFunction · 0.85
LEfloatintFunction · 0.85
luaH_newkeyFunction · 0.85
luaH_getFunction · 0.85
luaK_numberKFunction · 0.85
luaK_floatFunction · 0.85
isSCnumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected