mirror of
https://github.com/mruby/mruby
synced 2026-06-08 16:11:16 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user