Add truncf16 and truncf128

Use the generic algorithms to provide implementations for these
routines.
This commit is contained in:
Trevor Gross
2025-01-12 04:12:56 +00:00
parent 6ac06a97e5
commit b558b365d3
13 changed files with 61 additions and 5 deletions

View File

@@ -199,3 +199,13 @@ impl HasDomain<f16> for crate::op::fabsf16::Routine {
impl HasDomain<f128> for crate::op::fabsf128::Routine {
const DOMAIN: Domain<f128> = Domain::<f128>::UNBOUNDED;
}
#[cfg(f16_enabled)]
impl HasDomain<f16> for crate::op::truncf16::Routine {
const DOMAIN: Domain<f16> = Domain::<f16>::UNBOUNDED;
}
#[cfg(f128_enabled)]
impl HasDomain<f128> for crate::op::truncf128::Routine {
const DOMAIN: Domain<f128> = Domain::<f128>::UNBOUNDED;
}

View File

@@ -141,6 +141,7 @@ libm_macros::for_each_function! {
lgamma_r, lgammaf_r, modf, modff, nextafter, nextafterf, pow,powf,
remquo, remquof, scalbn, scalbnf, sincos, sincosf, yn, ynf,
copysignf16, copysignf128, fabsf16, fabsf128,
truncf16, truncf128,
],
fn_extra: match MACRO_FN_NAME {
// Remap function names that are different between mpfr and libm
@@ -202,11 +203,13 @@ impl_no_round! {
#[cfg(f16_enabled)]
impl_no_round! {
fabsf16 => abs_mut;
truncf16 => trunc_mut;
}
#[cfg(f128_enabled)]
impl_no_round! {
fabsf128 => abs_mut;
truncf128 => trunc_mut;
}
/// Some functions are difficult to do in a generic way. Implement them here.