Pseudorandom Number Generator
https://en.wikipedia.org/wiki/Linear_congruential_generator
Example 1
(module
(global $seed (import "js" "global") (mut i32))
(func (export "rand") (result i32)
(local $s i32)
(i32.rem_s
(i32.add
(i32.mul
(i32.const 1103515245)
(get_global $seed)
)
(i32.const 12345)
)
(i32.const 2147483648)
)
tee_local $s
get_local $s
set_global $seed
))Example 2
Last updated
Was this helpful?