From 413a151a6bece80609f9951bb5d941009bdc7aa4 Mon Sep 17 00:00:00 2001 From: Kevin Newton Date: Fri, 5 Apr 2024 13:48:40 -0400 Subject: [ruby/prism] Explicitly cast from uint64_t to double for mid-square hash https://github.com/ruby/prism/commit/06c6501044 --- prism/prism.c | 4 ++-- 1 file 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))); } /** -- cgit v1.2.3