File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -106,7 +106,8 @@ u32 PcgRandom::range(u32 bound)
106
106
u32 threshhold = -bound % bound;
107
107
u32 r;
108
108
109
- while ((r = next ()) < threshhold);
109
+ while ((r = next ()) < threshhold)
110
+ ;
110
111
111
112
return r % bound;
112
113
}
@@ -127,6 +128,7 @@ void PcgRandom::bytes(void *out, size_t len)
127
128
128
129
size_t len_alignment = (uintptr_t )out % sizeof (u32);
129
130
if (len_alignment) {
131
+ len -= len_alignment;
130
132
r = next ();
131
133
while (len_alignment--) {
132
134
*outb = r & 0xFF ;
@@ -156,7 +158,7 @@ void PcgRandom::bytes(void *out, size_t len)
156
158
157
159
s32 PcgRandom::randNormalDist (s32 min, s32 max, int num_trials)
158
160
{
159
- u32 accum = 0 ;
161
+ s32 accum = 0 ;
160
162
for (int i = 0 ; i != num_trials; i++)
161
163
accum += range (min, max);
162
164
return ((float )accum / num_trials) + 0 .5f ;
You can’t perform that action at this time.
0 commit comments