Skip to content
Myr

stb.h rand: A few more long->int fixes

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Ethan Lee · committed by Ethan Lee · parent 59e9702 · Browse files · 1 file+6 added−5 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+6 added−5 removed

  • other:+6 added−5 removed

1 file+6 added−5 removed

modified:stb.h+6 added-5 removed
194 unmodified lines
195 Eugene Opalev196 Tim Sjostrand197 github:infatum198 Dave Butler (Croepha)199 Ethan Lee (flibitijibibo)200*/201202#include <stdarg.h>203
8065 unmodified lines
8269//8270// Random Numbers via Meresenne Twister or LCG8271//82728272STB_EXTERN unsigned int stb_srandLCG(unsigned long seed);8273STB_EXTERN unsigned int stb_srandLCG(unsigned int seed);8274STB_EXTERN unsigned int stb_randLCG(void);8275STB_EXTERN double stb_frandLCG(void);82768277STB_EXTERN void stb_srand(unsigned int seed);8278STB_EXTERN unsigned int stb_rand(void);8279STB_EXTERN double stb_frand(void);8280STB_EXTERN void stb_shuffle(void *p, size_t n, size_t sz,8280 unsigned long seed);8281 unsigned int seed);8282STB_EXTERN void stb_reverse(void *p, size_t n, size_t sz);82838284STB_EXTERN unsigned int stb_randLCG_explicit(unsigned int seed);8285
13 unmodified lines
8299}83008301static unsigned int stb__rand_seed=0;83028302unsigned int stb_srandLCG(unsigned long seed)8303unsigned int stb_srandLCG(unsigned int seed)8304{8305 unsigned int previous = stb__rand_seed;8306 stb__rand_seed = seed;8307 return previous;
10 unmodified lines
8318{8319 return stb_randLCG() / ((double) (1 << 16) * (1 << 16));8320}83218321void stb_shuffle(void *p, size_t n, size_t sz, unsigned long seed)8322void stb_shuffle(void *p, size_t n, size_t sz, unsigned int seed)8323{8324 char *a;8324 unsigned long old_seed;8325 unsigned int old_seed;8326 int i;8327 if (seed)8328 old_seed = stb_srandLCG(seed);8329 a = (char *) p + (n-1) * sz;
6141 unmodified lines