mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
mruby-bigint: fix signed/unsigned comparison warning
Cast base parameter to uint64_t in mpz_get_str power-of-2 path to resolve C4018 warning about signed/unsigned mismatch. The comparison now properly compares two unsigned values: ((uint64_t)1 << shift) with (uint64_t)base. Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -1942,7 +1942,7 @@ mpz_get_str(mpz_ctx_t *ctx, char *s, mrb_int sz, mrb_int base, mpz_t *x)
|
||||
|
||||
if ((base & (base - 1)) == 0) { // base is a power of 2
|
||||
int shift = 0;
|
||||
while (((uint64_t)1 << shift) < base) shift++;
|
||||
while (((uint64_t)1 << shift) < (uint64_t)base) shift++;
|
||||
mp_limb mask = (mp_limb)base - 1;
|
||||
mp_dbl_limb value = 0;
|
||||
int bits = 0;
|
||||
|
||||
Reference in New Issue
Block a user