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

Function I2d

third-party/lua-5.4.6/src/lmathlib.c:351–358  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349#define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1)))
350
351static lua_Number I2d (Rand64 x) {
352 SRand64 sx = (SRand64)(trim64(x) >> shift64_FIG);
353 lua_Number res = (lua_Number)(sx) * scaleFIG;
354 if (sx < 0)
355 res += l_mathop(1.0); /* correct the two's complement if negative */
356 lua_assert(0 <= res && res < 1);
357 return res;
358}
359
360/* convert a 'Rand64' to a 'lua_Unsigned' */
361#define I2UInt(x) ((lua_Unsigned)trim64(x))

Callers 1

math_randomFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected