| 95 | */ |
| 96 | #if !defined(l_hashfloat) |
| 97 | static 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 |