Zig NEWS

Discussion on: How to use the random number generator in Zig

Collapse
 
dozerman profile image
doz erman

Is there a way to cap the maximum? Like get a rnd between 0 and 32?

Collapse
 
falconerd profile image
Dylan Falconer

You can use the builtin @mod

const num = @mod(rand_impl.random().int(i32), 32);
Enter fullscreen mode Exit fullscreen mode