MCPcopy Create free account
hub / github.com/F-Stack/f-stack / bit_tohex

Function bit_tohex

app/redis-6.2.6/deps/lua/src/lua_bit.c:127–140  ·  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 == INT32_MIN) n = INT32_MIN+1;
135 if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
136 if (n > 8) n = 8;
137 for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; }
138 lua_pushlstring(L, buf, (size_t)n);
139 return 1;
140}
141
142static const struct luaL_Reg bit_funcs[] = {
143 { "tobit", bit_tobit },

Callers

nothing calls this directly

Calls 2

bargFunction · 0.85
lua_pushlstringFunction · 0.70

Tested by

no test coverage detected