diff options
| author | Kevin Newton <kddnewton@gmail.com> | 2024-04-05 13:48:40 -0400 |
|---|---|---|
| committer | git <svn-admin@ruby-lang.org> | 2024-04-05 19:24:01 +0000 |
| commit | 413a151a6bece80609f9951bb5d941009bdc7aa4 (patch) | |
| tree | 4c6ff689e70afba241aa35bf51e8e63dcc14c078 | |
| parent | 5e93cf9250bbdfeb409072ceaa29fa55fe2bd764 (diff) | |
[ruby/prism] Explicitly cast from uint64_t to double for mid-square hash
https://github.com/ruby/prism/commit/06c6501044
| -rw-r--r-- | prism/prism.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/prism/prism.c b/prism/prism.c index c5d33005cf..5d289fe011 100644 --- a/prism/prism.c +++ b/prism/prism.c @@ -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))); } /** |
