MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / mp_encode_lua_number

Function mp_encode_lua_number

deps/lua/src/lua_cmsgpack.c:367–375  ·  view source on GitHub ↗

Lua 5.2 and lower only has 64-bit doubles, so we need to * detect if the double may be representable as an int * for Lua < 5.3 */

Source from the content-addressed store, hash-verified

365 * detect if the double may be representable as an int
366 * for Lua < 5.3 */
367void mp_encode_lua_number(lua_State *L, mp_buf *buf) {
368 lua_Number n = lua_tonumber(L,-1);
369
370 if (IS_INT64_EQUIVALENT(n)) {
371 mp_encode_lua_integer(L, buf);
372 } else {
373 mp_encode_double(L,buf,(double)n);
374 }
375}
376
377void mp_encode_lua_type(lua_State *L, mp_buf *buf, int level);
378

Callers 1

mp_encode_lua_typeFunction · 0.85

Calls 3

lua_tonumberFunction · 0.85
mp_encode_lua_integerFunction · 0.85
mp_encode_doubleFunction · 0.85

Tested by

no test coverage detected