fdimf
This commit is contained in:
parent
965c736cc1
commit
480531461c
4 changed files with 29 additions and 5 deletions
|
|
@ -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
library/compiler-builtins/libm/src/math/fdimf.rs
Normal file
15
library/compiler-builtins/libm/src/math/fdimf.rs
Normal 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue