summaryrefslogtreecommitdiff
path: root/ext/bigdecimal
diff options
context:
space:
mode:
authorKenta Murata <mrkn@mrkn.jp>2021-01-12 16:54:36 +0900
committerKenta Murata <mrkn@mrkn.jp>2021-01-12 17:38:43 +0900
commitccabf4966f4c5a7e19fec52b690d07bf471fc5d1 (patch)
tree1be4bb1d91ef83657bbed2ebd5de73a136524fac /ext/bigdecimal
parent1eb8eb55c27b19e36d5bd23ce27f7ec2b9a7f521 (diff)
[ruby/bigdecimal] Fix length calculation in rb_uint64_convert_to_BigDecimal
https://github.com/ruby/bigdecimal/commit/14e53ed7f6
Diffstat (limited to 'ext/bigdecimal')
-rw-r--r--ext/bigdecimal/bigdecimal.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c
index 298e736..4e124bd 100644
--- a/ext/bigdecimal/bigdecimal.c
+++ b/ext/bigdecimal/bigdecimal.c
@@ -2697,8 +2697,7 @@ rb_uint64_convert_to_BigDecimal(uint64_t uval, RB_UNUSED_VAR(size_t digs), int r
vp->frac[0] = (DECDIG)uval;
}
else {
- const size_t len10 = ceil(LOG10_2 * bit_length(uval));
- size_t len = roomof(len10, BASE_FIG);
+ const size_t len = (size_t)ceil(log10(uval) / BASE_FIG);
vp = VpAllocReal(len);
vp->MaxPrec = len;