File tree Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Expand file tree Collapse file tree 2 files changed +22
-8
lines changed Original file line number Diff line number Diff line change @@ -908,10 +908,17 @@ impl f32 {
908908 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
909909 #[ inline]
910910 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 ( )
915922 }
916923 }
917924
Original file line number Diff line number Diff line change @@ -831,10 +831,17 @@ impl f64 {
831831 #[ stable( feature = "rust1" , since = "1.0.0" ) ]
832832 #[ inline]
833833 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 ( )
838845 }
839846 }
840847
You can’t perform that action at this time.
0 commit comments