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