From 2e997f24f12e455b01fd2e9d8925d5c29f5c2fc5 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 22 Aug 2016 12:39:18 +0000 Subject: [PATCH] =?UTF-8?q?math:=20allow=20rand(0),=20it=E2=80=99s=20argua?= =?UTF-8?q?bly=20better=20than=20raising=20SIGFPE.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lol/math/rand.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lol/math/rand.h b/src/lol/math/rand.h index 2c0bc604..5ad263cd 100644 --- a/src/lol/math/rand.h +++ b/src/lol/math/rand.h @@ -29,7 +29,7 @@ template static inline T rand(T a, T b); /* One-value random number generators */ template static inline T rand(T a) { - return rand() % a; + return a ? rand() % a : T(0); } template<> inline half rand(half a)