From: Brendan Hansen Date: Thu, 30 Mar 2023 23:10:30 +0000 (-0500) Subject: added: `math.fmod` X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=4dd2e016b2cef85dc908e1dbb1b8441ead610565;p=onyx.git added: `math.fmod` --- diff --git a/core/math/math.onyx b/core/math/math.onyx index 43740c28..1bb168ed 100644 --- a/core/math/math.onyx +++ b/core/math/math.onyx @@ -249,6 +249,18 @@ ilog2 :: (a: u64) -> u64 { } +fmod :: #match #local {} + +#overload +fmod :: (x, y: f64) -> f64 { + return x - trunc(x / y) * y; +} + +#overload +fmod :: (x, y: f32) -> f32 { + return x - trunc(x / y) * y; +} + // These function are overloaded in order to use the builtin WASM intrinsics for the // operation first, and then default to a polymorphic function that works on any type.