Closed zazu7765 closed 1 month ago
The first code snippet on the Random Numbers page for zig 0.13.0 uses std.os.getrandom which is not yet available... The change is to simply revert back to the posix.getrandom that we see in zig 0.12.0.
std.os.getrandom
posix.getrandom
The commit change is here https://github.com/Sobeston/zig.guide/commit/14283dca1e48d247d2f91f205497d083bef5723f
test "random numbers" { var prng = std.rand.DefaultPrng.init(blk: { var seed: u64 = undefined; try std.os.getrandom(std.mem.asBytes(&seed)); break :blk seed; }); const rand = prng.random(); const a = rand.float(f32); const b = rand.boolean(); const c = rand.int(u8); const d = rand.intRangeAtMost(u8, 0, 255); //suppress unused constant compile error _ = .{ a, b, c, d }; }
The first code snippet on the Random Numbers page for zig 0.13.0 uses
std.os.getrandom
which is not yet available... The change is to simply revert back to theposix.getrandom
that we see in zig 0.12.0.The commit change is here https://github.com/Sobeston/zig.guide/commit/14283dca1e48d247d2f91f205497d083bef5723f