From 4dd2e016b2cef85dc908e1dbb1b8441ead610565 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 30 Mar 2023 18:10:30 -0500 Subject: [PATCH] added: `math.fmod` --- core/math/math.onyx | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. -- 2.25.1