ruby-changes:64837
From: Kenta <ko1@a...>
Date: Tue, 12 Jan 2021 17:53:44 +0900 (JST)
Subject: [ruby-changes:64837] ccabf4966f (master): [ruby/bigdecimal] Fix length calculation in rb_uint64_convert_to_BigDecimal
https://git.ruby-lang.org/ruby.git/commit/?id=ccabf4966f From ccabf4966f4c5a7e19fec52b690d07bf471fc5d1 Mon Sep 17 00:00:00 2001 From: Kenta Murata <mrkn@m...> Date: Tue, 12 Jan 2021 16:54:36 +0900 Subject: [ruby/bigdecimal] Fix length calculation in rb_uint64_convert_to_BigDecimal https://github.com/ruby/bigdecimal/commit/14e53ed7f6 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 https://github.com/ruby/ruby/blob/trunk/ext/bigdecimal/bigdecimal.c#L2697 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; -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/