MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / luaO_ceillog2

Function luaO_ceillog2

third-party/lua-5.5.0/src/lobject.c:37–52  ·  view source on GitHub ↗

** Computes ceil(log2(x)), which is the smallest integer n such that ** x <= (1 << n). */

Source from the content-addressed store, hash-verified

35** x <= (1 << n).
36*/
37lu_byte luaO_ceillog2 (unsigned int x) {
38 static const lu_byte log_2[256] = { /* log_2[i - 1] = ceil(log2(i)) */
39 0,1,2,2,3,3,3,3,4,4,4,4,4,4,4,4,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,
40 6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,6,
41 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
42 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
43 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
44 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
45 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,
46 8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8,8
47 };
48 int l = 0;
49 x--;
50 while (x >= 256) { l += 8; x >>= 8; }
51 return cast_byte(l + log_2[x]);
52}
53
54/*
55** Encodes 'p'% as a floating-point byte, represented as (eeeexxxx).

Callers 5

luaO_codeparamFunction · 0.70
countintFunction · 0.70
setnodevectorFunction · 0.70
hash_searchFunction · 0.70
luaK_settablesizeFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected