| 117 | */ |
| 118 | #if !defined(l_hashfloat) |
| 119 | static int l_hashfloat (lua_Number n) { |
| 120 | int i; |
| 121 | lua_Integer ni; |
| 122 | n = l_mathop(frexp)(n, &i) * -cast_num(INT_MIN); |
| 123 | if (!lua_numbertointeger(n, &ni)) { /* is 'n' inf/-inf/NaN? */ |
| 124 | lua_assert(luai_numisnan(n) || l_mathop(fabs)(n) == cast_num(HUGE_VAL)); |
| 125 | return 0; |
| 126 | } |
| 127 | else { /* normal case */ |
| 128 | unsigned int u = cast_uint(i) + cast_uint(ni); |
| 129 | return cast_int(u <= cast_uint(INT_MAX) ? u : ~u); |
| 130 | } |
| 131 | } |
| 132 | #endif |
| 133 | |
| 134 |