| 103 | */ |
| 104 | #if !defined(l_hashfloat) |
| 105 | static int l_hashfloat(lua_Number n) { |
| 106 | int i; |
| 107 | lua_Integer ni; |
| 108 | n = l_mathop(frexp)(n, &i) * -cast_num(INT_MIN); |
| 109 | if (!lua_numbertointeger(n, &ni)) { /* is 'n' inf/-inf/NaN? */ |
| 110 | lua_assert(luai_numisnan(n) || l_mathop(fabs)(n) == cast_num(HUGE_VAL)); |
| 111 | return 0; |
| 112 | } |
| 113 | else { /* normal case */ |
| 114 | unsigned int u = lua_cast(unsigned int, i) + lua_cast(unsigned int, ni); |
| 115 | return cast_int(u <= lua_cast(unsigned int, INT_MAX) ? u : ~u); |
| 116 | } |
| 117 | } |
| 118 | #endif |
| 119 | |
| 120 | |