File tree 2 files changed +22
-8
lines changed
2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -908,10 +908,17 @@ impl f32 {
908
908
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
909
909
#[ inline]
910
910
pub fn asinh ( self ) -> f32 {
911
- if self == NEG_INFINITY {
912
- NEG_INFINITY
913
- } else {
914
- ( self + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( )
911
+ match self {
912
+ x if x == NEG_INFINITY => NEG_INFINITY ,
913
+ x if x. is_sign_negative ( ) => {
914
+ let v = ( x + ( ( x * x) + 1.0 ) . sqrt ( ) ) . ln ( ) ;
915
+ if v. is_sign_negative ( ) {
916
+ v
917
+ } else {
918
+ -v
919
+ }
920
+ }
921
+ x => ( x + ( ( x * x) + 1.0 ) . sqrt ( ) ) . ln ( )
915
922
}
916
923
}
917
924
Original file line number Diff line number Diff line change @@ -831,10 +831,17 @@ impl f64 {
831
831
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
832
832
#[ inline]
833
833
pub fn asinh ( self ) -> f64 {
834
- if self == NEG_INFINITY {
835
- NEG_INFINITY
836
- } else {
837
- ( self + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( )
834
+ match self {
835
+ x if x == NEG_INFINITY => NEG_INFINITY ,
836
+ x if x. is_sign_negative ( ) => {
837
+ let v = ( x + ( ( x * x) + 1.0 ) . sqrt ( ) ) . ln ( ) ;
838
+ if v. is_sign_negative ( ) {
839
+ v
840
+ } else {
841
+ -v
842
+ }
843
+ }
844
+ x => ( x + ( ( x * x) + 1.0 ) . sqrt ( ) ) . ln ( )
838
845
}
839
846
}
840
847
You can’t perform that action at this time.
0 commit comments