From a0dd0550ad0ce6c2685b4449dac69e8816d8c7af Mon Sep 17 00:00:00 2001 From: Benjamin Schultzer Date: Wed, 3 Jul 2019 11:57:54 -0700 Subject: [PATCH] Add remainder This PR adds the missing `remainder` and `remainderf` found in musl libm respectly https://git.musl-libc.org/cgit/musl/tree/src/math/remainder.c and https://git.musl-libc.org/cgit/musl/tree/src/math/remainderf.c Signed-off-by: Benjamin Schultzer --- src/math/mod.rs | 4 ++++ src/math/remainder.rs | 5 +++++ src/math/remainderf.rs | 5 +++++ 3 files changed, 14 insertions(+) create mode 100644 src/math/remainder.rs create mode 100644 src/math/remainderf.rs diff --git a/src/math/mod.rs b/src/math/mod.rs index 35ffe1a..48b400a 100644 --- a/src/math/mod.rs +++ b/src/math/mod.rs @@ -148,6 +148,8 @@ mod modf; mod modff; mod pow; mod powf; +mod remainder; +mod remainderf; mod remquo; mod remquof; mod round; @@ -258,6 +260,8 @@ pub use self::modf::modf; pub use self::modff::modff; pub use self::pow::pow; pub use self::powf::powf; +pub use self::remainder::remainder; +pub use self::remainderf::remainderf; pub use self::remquo::remquo; pub use self::remquof::remquof; pub use self::round::round; diff --git a/src/math/remainder.rs b/src/math/remainder.rs new file mode 100644 index 0000000..e0f56da --- /dev/null +++ b/src/math/remainder.rs @@ -0,0 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] +pub fn remainder(x: f64, y: f64) -> (f64, i32) { + super::remquo(x, y) +} diff --git a/src/math/remainderf.rs b/src/math/remainderf.rs new file mode 100644 index 0000000..72fd0e2 --- /dev/null +++ b/src/math/remainderf.rs @@ -0,0 +1,5 @@ +#[inline] +#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] +pub fn remainderf(x: f32, y: f32) -> (f32, i32) { + super::remquof(x, y) +}