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

Function I2d

third-party/lua-5.5.0/src/lmathlib.c:379–386  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

377#define scaleFIG (l_mathop(0.5) / ((Rand64)1 << (FIGS - 1)))
378
379static lua_Number I2d (Rand64 x) {
380 SRand64 sx = (SRand64)(trim64(x) >> shift64_FIG);
381 lua_Number res = (lua_Number)(sx) * scaleFIG;
382 if (sx < 0)
383 res += l_mathop(1.0); /* correct the two's complement if negative */
384 lua_assert(0 <= res && res < 1);
385 return res;
386}
387
388/* convert a 'Rand64' to a 'lua_Unsigned' */
389#define I2UInt(x) ((lua_Unsigned)trim64(x))

Callers 1

math_randomFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected