This commit is contained in:
Jack Mott
2018-07-14 05:35:07 -05:00
parent 31ab74299b
commit efcca54277
4 changed files with 29 additions and 5 deletions
+7
View File
@@ -42,6 +42,8 @@ pub trait F32Ext: private::Sealed {
fn trunc(self) -> Self;
fn fdim(self, rhs: Self) -> Self;
#[cfg(todo)]
fn fract(self) -> Self;
@@ -156,6 +158,11 @@ impl F32Ext for f32 {
truncf(self)
}
#[inline]
fn fdim(self, rhs: Self) -> Self {
fdimf(self, rhs)
}
#[cfg(todo)]
#[inline]
fn fract(self) -> Self {
+15
View File
@@ -0,0 +1,15 @@
use super::isnanf;
pub fn fdimf(x: f32, y: f32) -> f32 {
if isnanf(x) {
x
} else if isnanf(y) {
y
} else {
if x > y {
x - y
} else {
0.0
}
}
}
+6 -4
View File
@@ -10,6 +10,7 @@ mod ceilf;
mod expf;
mod fabs;
mod fabsf;
mod fdimf;
mod floor;
mod floorf;
mod fmodf;
@@ -36,10 +37,11 @@ mod truncf;
//mod service;
pub use self::{
ceilf::ceilf, expf::expf, fabs::fabs, fabsf::fabsf, floor::floor, floorf::floorf, fmodf::fmodf,
hypot::hypot, hypotf::hypotf, log::log, log10::log10, log10f::log10f, log1p::log1p,
log1pf::log1pf, log2::log2, log2f::log2f, logf::logf, powf::powf, round::round, roundf::roundf,
scalbn::scalbn, scalbnf::scalbnf, sqrt::sqrt, sqrtf::sqrtf, trunc::trunc, truncf::truncf,
ceilf::ceilf, expf::expf, fabs::fabs, fabsf::fabsf, fdimf::fdimf, floor::floor, floorf::floorf,
fmodf::fmodf, hypot::hypot, hypotf::hypotf, log::log, log10::log10, log10f::log10f,
log1p::log1p, log1pf::log1pf, log2::log2, log2f::log2f, logf::logf, powf::powf, round::round,
roundf::roundf, scalbn::scalbn, scalbnf::scalbnf, sqrt::sqrt, sqrtf::sqrtf, trunc::trunc,
truncf::truncf,
};
fn isnanf(x: f32) -> bool {
+1 -1
View File
@@ -662,7 +662,6 @@ f32_f32! {
// coshf,
// exp2f,
expf,
// fdimf,
log10f,
log1pf,
log2f,
@@ -679,6 +678,7 @@ f32_f32! {
// With signature `fn(f32, f32) -> f32`
f32f32_f32! {
// atan2f,
fdimf,
hypotf,
fmodf,
powf,