Skip to content

Commit 761b127

Browse files
committedMar 22, 2015
Fix some loose ends from 3993093
1 parent 3993093 commit 761b127

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed
 

Diff for: ‎src/noise.cpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ u32 PcgRandom::range(u32 bound)
106106
u32 threshhold = -bound % bound;
107107
u32 r;
108108

109-
while ((r = next()) < threshhold);
109+
while ((r = next()) < threshhold)
110+
;
110111

111112
return r % bound;
112113
}
@@ -127,6 +128,7 @@ void PcgRandom::bytes(void *out, size_t len)
127128

128129
size_t len_alignment = (uintptr_t)out % sizeof(u32);
129130
if (len_alignment) {
131+
len -= len_alignment;
130132
r = next();
131133
while (len_alignment--) {
132134
*outb = r & 0xFF;
@@ -156,7 +158,7 @@ void PcgRandom::bytes(void *out, size_t len)
156158

157159
s32 PcgRandom::randNormalDist(s32 min, s32 max, int num_trials)
158160
{
159-
u32 accum = 0;
161+
s32 accum = 0;
160162
for (int i = 0; i != num_trials; i++)
161163
accum += range(min, max);
162164
return ((float)accum / num_trials) + 0.5f;

0 commit comments

Comments
 (0)
Please sign in to comment.