+20
-4
@@ -73,8 +73,7 @@ pub trait F32Ext: private::Sealed + Sized {
|
||||
|
||||
fn abs(self) -> Self;
|
||||
|
||||
// NOTE depends on unstable intrinsics::copysignf32
|
||||
// fn signum(self) -> Self;
|
||||
fn signum(self) -> Self;
|
||||
|
||||
fn mul_add(self, a: Self, b: Self) -> Self;
|
||||
|
||||
@@ -178,6 +177,15 @@ impl F32Ext for f32 {
|
||||
fabsf(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn signum(self) -> Self {
|
||||
if self.is_nan() {
|
||||
f32::NAN
|
||||
} else {
|
||||
copysignf(1., self)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_add(self, a: Self, b: Self) -> Self {
|
||||
fmaf(self, a, b)
|
||||
@@ -361,8 +369,7 @@ pub trait F64Ext: private::Sealed + Sized {
|
||||
|
||||
fn abs(self) -> Self;
|
||||
|
||||
// NOTE depends on unstable intrinsics::copysignf64
|
||||
// fn signum(self) -> Self;
|
||||
fn signum(self) -> Self;
|
||||
|
||||
fn mul_add(self, a: Self, b: Self) -> Self;
|
||||
|
||||
@@ -466,6 +473,15 @@ impl F64Ext for f64 {
|
||||
fabs(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn signum(self) -> Self {
|
||||
if self.is_nan() {
|
||||
f64::NAN
|
||||
} else {
|
||||
copysign(1., self)
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn mul_add(self, a: Self, b: Self) -> Self {
|
||||
fma(self, a, b)
|
||||
|
||||
Reference in New Issue
Block a user