@@ -244,7 +244,7 @@ impl f64 {
244
244
pub fn div_euclid ( self , rhs : f64 ) -> f64 {
245
245
let q = ( self / rhs) . trunc ( ) ;
246
246
if self % rhs < 0.0 {
247
- return if rhs > 0.0 { q - 1.0 } else { q + 1.0 }
247
+ return if rhs > 0.0 { q - 1.0 } else { q + 1.0 } ;
248
248
}
249
249
q
250
250
}
@@ -437,9 +437,9 @@ impl f64 {
437
437
pub fn log2 ( self ) -> f64 {
438
438
self . log_wrapper ( |n| {
439
439
#[ cfg( target_os = "android" ) ]
440
- return crate :: sys:: android:: log2f64 ( n) ;
440
+ return crate :: sys:: android:: log2f64 ( n) ;
441
441
#[ cfg( not( target_os = "android" ) ) ]
442
- return unsafe { intrinsics:: log2f64 ( n) } ;
442
+ return unsafe { intrinsics:: log2f64 ( n) } ;
443
443
} )
444
444
}
445
445
@@ -481,16 +481,16 @@ impl f64 {
481
481
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
482
482
#[ inline]
483
483
#[ rustc_deprecated( since = "1.10.0" ,
484
- reason = "you probably meant `(self - other).abs()`: \
484
+ reason = "you probably meant `(self - other).abs()`: \
485
485
this operation is `(self - other).max(0.0)` \
486
486
except that `abs_sub` also propagates NaNs (also \
487
487
known as `fdim` in C). If you truly need the positive \
488
488
difference, consider using that expression or the C function \
489
489
`fdim`, depending on how you wish to handle NaN (please consider \
490
490
filing an issue describing your use-case too).") ]
491
- pub fn abs_sub ( self , other : f64 ) -> f64 {
492
- unsafe { cmath:: fdim ( self , other) }
493
- }
491
+ pub fn abs_sub ( self , other : f64 ) -> f64 {
492
+ unsafe { cmath:: fdim ( self , other) }
493
+ }
494
494
495
495
/// Takes the cubic root of a number.
496
496
///
@@ -831,9 +831,10 @@ impl f64 {
831
831
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
832
832
#[ inline]
833
833
pub fn asinh ( self ) -> f64 {
834
- match self {
835
- x if x == NEG_INFINITY => NEG_INFINITY ,
836
- x => ( x + ( ( x * x) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
834
+ if self == NEG_INFINITY {
835
+ NEG_INFINITY
836
+ } else {
837
+ ( self + ( ( self * self ) + 1.0 ) . sqrt ( ) ) . ln ( ) . copysign ( self )
837
838
}
838
839
}
839
840
@@ -852,9 +853,10 @@ impl f64 {
852
853
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
853
854
#[ inline]
854
855
pub fn acosh ( self ) -> f64 {
855
- match self {
856
- x if x < 1.0 => NAN ,
857
- x => ( x + ( ( x * x) - 1.0 ) . sqrt ( ) ) . ln ( ) ,
856
+ if self < 1.0 {
857
+ NAN
858
+ } else {
859
+ ( self + ( ( self * self ) - 1.0 ) . sqrt ( ) ) . ln ( )
858
860
}
859
861
}
860
862
@@ -1187,7 +1189,7 @@ mod tests {
1187
1189
assert_eq ! ( ( -0f64 ) . abs( ) , 0f64 ) ;
1188
1190
assert_eq ! ( ( -1f64 ) . abs( ) , 1f64 ) ;
1189
1191
assert_eq ! ( NEG_INFINITY . abs( ) , INFINITY ) ;
1190
- assert_eq ! ( ( 1f64 / NEG_INFINITY ) . abs( ) , 0f64 ) ;
1192
+ assert_eq ! ( ( 1f64 / NEG_INFINITY ) . abs( ) , 0f64 ) ;
1191
1193
assert ! ( NAN . abs( ) . is_nan( ) ) ;
1192
1194
}
1193
1195
@@ -1199,7 +1201,7 @@ mod tests {
1199
1201
assert_eq ! ( ( -0f64 ) . signum( ) , -1f64 ) ;
1200
1202
assert_eq ! ( ( -1f64 ) . signum( ) , -1f64 ) ;
1201
1203
assert_eq ! ( NEG_INFINITY . signum( ) , -1f64 ) ;
1202
- assert_eq ! ( ( 1f64 / NEG_INFINITY ) . signum( ) , -1f64 ) ;
1204
+ assert_eq ! ( ( 1f64 / NEG_INFINITY ) . signum( ) , -1f64 ) ;
1203
1205
assert ! ( NAN . signum( ) . is_nan( ) ) ;
1204
1206
}
1205
1207
@@ -1211,7 +1213,7 @@ mod tests {
1211
1213
assert ! ( !( -0f64 ) . is_sign_positive( ) ) ;
1212
1214
assert ! ( !( -1f64 ) . is_sign_positive( ) ) ;
1213
1215
assert ! ( !NEG_INFINITY . is_sign_positive( ) ) ;
1214
- assert ! ( !( 1f64 / NEG_INFINITY ) . is_sign_positive( ) ) ;
1216
+ assert ! ( !( 1f64 / NEG_INFINITY ) . is_sign_positive( ) ) ;
1215
1217
assert ! ( NAN . is_sign_positive( ) ) ;
1216
1218
assert ! ( !( -NAN ) . is_sign_positive( ) ) ;
1217
1219
}
@@ -1224,7 +1226,7 @@ mod tests {
1224
1226
assert ! ( ( -0f64 ) . is_sign_negative( ) ) ;
1225
1227
assert ! ( ( -1f64 ) . is_sign_negative( ) ) ;
1226
1228
assert ! ( NEG_INFINITY . is_sign_negative( ) ) ;
1227
- assert ! ( ( 1f64 / NEG_INFINITY ) . is_sign_negative( ) ) ;
1229
+ assert ! ( ( 1f64 / NEG_INFINITY ) . is_sign_negative( ) ) ;
1228
1230
assert ! ( !NAN . is_sign_negative( ) ) ;
1229
1231
assert ! ( ( -NAN ) . is_sign_negative( ) ) ;
1230
1232
}
@@ -1433,7 +1435,8 @@ mod tests {
1433
1435
assert_eq ! ( inf. asinh( ) , inf) ;
1434
1436
assert_eq ! ( neg_inf. asinh( ) , neg_inf) ;
1435
1437
assert ! ( nan. asinh( ) . is_nan( ) ) ;
1436
- assert ! ( ( -0.0f64 ) . asinh( ) . is_sign_negative( ) ) ; // issue 63271
1438
+ assert ! ( ( -0.0f64 ) . asinh( ) . is_sign_negative( ) ) ;
1439
+ // issue 63271
1437
1440
assert_approx_eq ! ( 2.0f64 . asinh( ) , 1.443635475178810342493276740273105f64 ) ;
1438
1441
assert_approx_eq ! ( ( -2.0f64 ) . asinh( ) , -1.443635475178810342493276740273105f64 ) ;
1439
1442
}
0 commit comments