summaryrefslogtreecommitdiff
path: root/bignum.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-04 18:10:41 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2022-10-14 19:23:25 +0900
commit5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5 (patch)
tree23a8d2af84fed1b1f080953a5a1eab0b73c3ea8e /bignum.c
parentee8bcbf40578c0c4e60063a3e0c86439a6891131 (diff)
downloadruby-5ccb625fbbd1e774636a9fdbe0bf1c3d38e085d5.tar.gz
Use `roomof` macro for rounding up divisions
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/bignum.c b/bignum.c
index 9901a807b1..4f8349dd17 100644
--- a/bignum.c
+++ b/bignum.c
@@ -977,7 +977,7 @@ integer_unpack_num_bdigits_small(size_t numwords, size_t wordsize, size_t nails,
{
/* nlp_bits stands for number of leading padding bits */
size_t num_bits = (wordsize * CHAR_BIT - nails) * numwords;
- size_t num_bdigits = (num_bits + BITSPERDIG - 1) / BITSPERDIG;
+ size_t num_bdigits = roomof(num_bits, BITSPERDIG);
*nlp_bits_ret = (int)(num_bdigits * BITSPERDIG - num_bits);
return num_bdigits;
}
@@ -987,7 +987,7 @@ integer_unpack_num_bdigits_generic(size_t numwords, size_t wordsize, size_t nail
{
/* BITSPERDIG = SIZEOF_BDIGIT * CHAR_BIT */
/* num_bits = (wordsize * CHAR_BIT - nails) * numwords */
- /* num_bdigits = (num_bits + BITSPERDIG - 1) / BITSPERDIG */
+ /* num_bdigits = roomof(num_bits, BITSPERDIG) */
/* num_bits = CHAR_BIT * (wordsize * numwords) - nails * numwords = CHAR_BIT * num_bytes1 - nails * numwords */
size_t num_bytes1 = wordsize * numwords;