mruby-random: fix unary minus on unsigned type warning

replace (-rot) with (32 - rot) to avoid msvc warning c4146. both
expressions are equivalent when masked with & 31, but the latter
is clearer and doesn't trigger warnings about negating unsigned values.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2025-10-16 16:12:11 +09:00
parent f25fadf46c
commit 0082dfb7e5
+1 -1
View File
@@ -82,7 +82,7 @@ rand_uint32(rand_state *rng)
uint32_t rot = (uint32_t)(oldstate >> 59u);
/* Rotate right by rot bits (handles rot=0 case correctly) */
return (xorshifted >> rot) | (xorshifted << ((-rot) & 31));
return (xorshifted >> rot) | (xorshifted << ((32 - rot) & 31));
}
#ifndef MRB_NO_FLOAT