MCPcopy Create free account
hub / github.com/DFHack/dfhack / l_hashfloat

Function l_hashfloat

depends/lua/src/ltable.c:97–109  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

95*/
96#if !defined(l_hashfloat)
97static int l_hashfloat (lua_Number n) {
98 int i;
99 lua_Integer ni;
100 n = l_mathop(frexp)(n, &i) * -cast_num(INT_MIN);
101 if (!lua_numbertointeger(n, &ni)) { /* is 'n' inf/-inf/NaN? */
102 lua_assert(luai_numisnan(n) || l_mathop(fabs)(n) == cast_num(HUGE_VAL));
103 return 0;
104 }
105 else { /* normal case */
106 unsigned int u = cast(unsigned int, i) + cast(unsigned int, ni);
107 return cast_int(u <= cast(unsigned int, INT_MAX) ? u : ~u);
108 }
109}
110#endif
111
112

Callers 1

mainpositionFunction · 0.85

Calls 1

castFunction · 0.85

Tested by

no test coverage detected