From 3bc6595f0f84c3bb565434e5d6e80ff45fd28c3a Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Wed, 20 Jan 2021 19:19:58 -0600 Subject: [PATCH] fixed math.pow with negatives causing infinite loops --- core/math.onyx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/math.onyx b/core/math.onyx index 7ab959c3..ad3fa9ac 100644 --- a/core/math.onyx +++ b/core/math.onyx @@ -96,6 +96,9 @@ pow_int :: proc (base: $T, p: i32) -> T { } pow_float :: proc (base: $T, p: T) -> T { + if p == 0 do return 1; + if p < 0 do return 1 / pow_float(base, -p); + if p >= 1 { tmp := pow_float(p = p / 2, base = base); return tmp * tmp; -- 2.25.1