mirror of
https://github.com/janet-lang/janet
synced 2024-12-27 00:40:26 +00:00
normalize zero without branching
This commit is contained in:
parent
d7ea122cf7
commit
3cd1657387
@ -322,7 +322,7 @@ int32_t janet_hash(Janet x) {
|
|||||||
uint64_t u;
|
uint64_t u;
|
||||||
} as;
|
} as;
|
||||||
as.d = janet_unwrap_number(x);
|
as.d = janet_unwrap_number(x);
|
||||||
as.d = as.d == 0 ? 0 : as.d; /* normalize negative 0 */
|
as.d += 0.0; /* normalize negative 0 */
|
||||||
uint32_t lo = (uint32_t)(as.u & 0xFFFFFFFF);
|
uint32_t lo = (uint32_t)(as.u & 0xFFFFFFFF);
|
||||||
uint32_t hi = (uint32_t)(as.u >> 32);
|
uint32_t hi = (uint32_t)(as.u >> 32);
|
||||||
uint32_t hilo = (hi ^ lo) * 2654435769u;
|
uint32_t hilo = (hi ^ lo) * 2654435769u;
|
||||||
|
Loading…
Reference in New Issue
Block a user