Skip to content

Commit

Permalink
[ruby/prism] Explicitly cast from uint64_t to double for mid-square hash
Browse files Browse the repository at this point in the history
  • Loading branch information
kddnewton authored and matzbot committed Apr 5, 2024
1 parent 5e93cf9 commit 413a151
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions prism/prism.c
Expand Up @@ -811,11 +811,11 @@ static uint32_t
pm_locals_hash(pm_constant_id_t name) {
uint64_t square = (uint64_t) name * (uint64_t) name;

uint32_t num_digits = (uint32_t) floor(log10(square) + 1);
uint32_t num_digits = (uint32_t) floor(log10((double) square) + 1);
uint32_t start = num_digits / 2;
uint32_t end = start + 1;

return (uint32_t) (((uint64_t) ((square / pow(10, start))) % (uint64_t) pow(10, end)));
return (uint32_t) (((uint64_t) ((square / ((uint64_t) pow(10, (double) start)))) % (uint64_t) pow(10, (double) end)));
}

/**
Expand Down

0 comments on commit 413a151

Please sign in to comment.