MCPcopy Create free account
hub / github.com/TASEmulators/fceux / bit_tohex

Function bit_tohex

src/lua-engine.cpp:5830–5842  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5828}
5829
5830static int bit_tohex(lua_State *L)
5831{
5832 UBits b = barg(L, 1);
5833 SBits n = lua_isnone(L, 2) ? 8 : (SBits)barg(L, 2);
5834 const char *hexdigits = "0123456789abcdef";
5835 char buf[8];
5836 int i;
5837 if (n < 0) { n = -n; hexdigits = "0123456789ABCDEF"; }
5838 if (n > 8) n = 8;
5839 for (i = (int)n; --i >= 0; ) { buf[i] = hexdigits[b & 15]; b >>= 4; }
5840 lua_pushlstring(L, buf, (size_t)n);
5841 return 1;
5842}
5843
5844static const struct luaL_Reg bit_funcs[] = {
5845 { "tobit", bit_tobit },

Callers

nothing calls this directly

Calls 2

bargFunction · 0.85
lua_pushlstringFunction · 0.85

Tested by

no test coverage detected