File tree 2 files changed +6
-10
lines changed
2 files changed +6
-10
lines changed Original file line number Diff line number Diff line change @@ -832,11 +832,7 @@ impl f32 {
832
832
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
833
833
#[ inline]
834
834
pub fn asinh ( self ) -> f32 {
835
- if self == Self :: NEG_INFINITY {
836
- Self :: NEG_INFINITY
837
- } else {
838
- ( self + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
839
- }
835
+ ( self . abs ( ) + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
840
836
}
841
837
842
838
/// Inverse hyperbolic cosine function.
@@ -1413,6 +1409,8 @@ mod tests {
1413
1409
assert ! ( ( -0.0f32 ) . asinh( ) . is_sign_negative( ) ) ; // issue 63271
1414
1410
assert_approx_eq ! ( 2.0f32 . asinh( ) , 1.443635475178810342493276740273105f32 ) ;
1415
1411
assert_approx_eq ! ( ( -2.0f32 ) . asinh( ) , -1.443635475178810342493276740273105f32 ) ;
1412
+ // regression test for the catastrophic cancellation fixed in 72486
1413
+ assert_approx_eq ! ( ( -3000.0f32 ) . asinh( ) , -8.699514775987968673236893537700647f32 ) ;
1416
1414
}
1417
1415
1418
1416
#[ test]
Original file line number Diff line number Diff line change @@ -834,11 +834,7 @@ impl f64 {
834
834
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
835
835
#[ inline]
836
836
pub fn asinh ( self ) -> f64 {
837
- if self == Self :: NEG_INFINITY {
838
- Self :: NEG_INFINITY
839
- } else {
840
- ( self + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
841
- }
837
+ ( self . abs ( ) + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
842
838
}
843
839
844
840
/// Inverse hyperbolic cosine function.
@@ -1442,6 +1438,8 @@ mod tests {
1442
1438
// issue 63271
1443
1439
assert_approx_eq ! ( 2.0f64 . asinh( ) , 1.443635475178810342493276740273105f64 ) ;
1444
1440
assert_approx_eq ! ( ( -2.0f64 ) . asinh( ) , -1.443635475178810342493276740273105f64 ) ;
1441
+ // regression test for the catastrophic cancellation fixed in 72486
1442
+ assert_approx_eq ! ( ( -67452098.07139316f64 ) . asinh( ) , -18.72007542627454439398548429400083 ) ;
1445
1443
}
1446
1444
1447
1445
#[ test]
You can’t perform that action at this time.
0 commit comments