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

Function luaO_int2fb

freebsd/contrib/openzfs/module/lua/lobject.c:32–40  ·  view source on GitHub ↗

** converts an integer to a "floating point byte", represented as ** (eeeeexxx), where the real value is (1xxx) * 2^(eeeee - 1) if ** eeeee != 0 and (xxx) otherwise. */

Source from the content-addressed store, hash-verified

30** eeeee != 0 and (xxx) otherwise.
31*/
32int luaO_int2fb (unsigned int x) {
33 int e = 0; /* exponent */
34 if (x < 8) return x;
35 while (x >= 0x10) {
36 x = (x+1) >> 1;
37 e++;
38 }
39 return ((e+1) << 3) | (cast_int(x) - 8);
40}
41
42
43/* converts back */

Callers 1

constructorFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected