Used copysign to avoid unnecessary branches.
This commit is contained in:
parent
64e3a10a82
commit
535efa4afd
2 changed files with 2 additions and 18 deletions
|
|
@ -910,15 +910,7 @@ impl f32 {
|
|||
pub fn asinh(self) -> f32 {
|
||||
match self {
|
||||
x if x == NEG_INFINITY => NEG_INFINITY,
|
||||
x if x.is_sign_negative() => {
|
||||
let v = (x + ((x * x) + 1.0).sqrt()).ln();
|
||||
if v.is_sign_negative() {
|
||||
v
|
||||
} else {
|
||||
-v
|
||||
}
|
||||
}
|
||||
x => (x + ((x * x) + 1.0).sqrt()).ln()
|
||||
x => (x + ((x * x) + 1.0).sqrt()).ln().copysign(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -833,15 +833,7 @@ impl f64 {
|
|||
pub fn asinh(self) -> f64 {
|
||||
match self {
|
||||
x if x == NEG_INFINITY => NEG_INFINITY,
|
||||
x if x.is_sign_negative() => {
|
||||
let v = (x + ((x * x) + 1.0).sqrt()).ln();
|
||||
if v.is_sign_negative() {
|
||||
v
|
||||
} else {
|
||||
-v
|
||||
}
|
||||
}
|
||||
x => (x + ((x * x) + 1.0).sqrt()).ln()
|
||||
x => (x + ((x * x) + 1.0).sqrt()).ln().copysign(self)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue