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

Function bit_tohex

deps/lua/src/lua_bit.c:127–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127static int bit_tohex(lua_State *L)
128{
129 UBits b = barg(L, 1);
130 SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2);
131 const char *hexdigits = "0123456789abcdef";
132 char buf[8];
133 int i;
134 if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
135 if (n > 8) n = 8;
136 for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; }
137 lua_pushlstring(L, buf, (size_t)n);
138 return 1;
139}
140
141static const struct luaL_Reg bit_funcs[] = {
142 { "tobit", bit_tobit },

Callers

nothing calls this directly

Calls 2

bargFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected