MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaV_flttointeger

Function luaV_flttointeger

extlibs/lua/src/lvm.c:121–129  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

119** try to convert a float to an integer, rounding according to 'mode'.
120*/
121int luaV_flttointeger (lua_Number n, lua_Integer *p, F2Imod mode) {
122 lua_Number f = l_floor(n);
123 if (n != f) { /* not an integral value? */
124 if (mode == F2Ieq) return 0; /* fails if mode demands integral value */
125 else if (mode == F2Iceil) /* needs ceil? */
126 f += 1; /* convert floor to ceil (remember: n != f) */
127 }
128 return lua_numbertointeger(f, p);
129}
130
131
132/*

Callers 9

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_floatFunction · 0.85
isSCnumberFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected