From 8f38b06c60a4bf028d931f7e2c9fc45b70cf7bd7 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 10 Sep 2020 15:42:07 +0100 Subject: [PATCH] Add sanity conversion for rand.norm_float64 --- core/math/rand/normal.odin | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/math/rand/normal.odin b/core/math/rand/normal.odin index 2785abd9d..653ca6c3b 100644 --- a/core/math/rand/normal.odin +++ b/core/math/rand/normal.odin @@ -116,6 +116,12 @@ norm_float64 :: proc(r: ^Rand = nil) -> f64 { 0.008624485, 0.005548995, 0.0026696292, }; + r := r; + if r == nil { + // NOTE(bill, 2020-09-07): Do this so that people can + // enforce the global random state if necessary with `nil` + r = &global_rand; + } for { j := i32(uint32(r));