@@ -426,7 +426,7 @@ impl f64 {
426
426
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
427
427
#[ inline]
428
428
pub fn ln ( self ) -> f64 {
429
- self . log_wrapper ( |n| unsafe { intrinsics:: logf64 ( n) } )
429
+ crate :: sys :: log_wrapper ( self , |n| unsafe { intrinsics:: logf64 ( n) } )
430
430
}
431
431
432
432
/// Returns the logarithm of the number with respect to an arbitrary base.
@@ -470,7 +470,7 @@ impl f64 {
470
470
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
471
471
#[ inline]
472
472
pub fn log2 ( self ) -> f64 {
473
- self . log_wrapper ( crate :: sys:: log2f64)
473
+ crate :: sys :: log_wrapper ( self , crate :: sys:: log2f64)
474
474
}
475
475
476
476
/// Returns the base 10 logarithm of the number.
@@ -490,7 +490,7 @@ impl f64 {
490
490
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
491
491
#[ inline]
492
492
pub fn log10 ( self ) -> f64 {
493
- self . log_wrapper ( |n| unsafe { intrinsics:: log10f64 ( n) } )
493
+ crate :: sys :: log_wrapper ( self , |n| unsafe { intrinsics:: log10f64 ( n) } )
494
494
}
495
495
496
496
/// The positive difference of two numbers.
@@ -925,28 +925,4 @@ impl f64 {
925
925
pub fn atanh ( self ) -> f64 {
926
926
0.5 * ( ( 2.0 * self ) / ( 1.0 - self ) ) . ln_1p ( )
927
927
}
928
-
929
- // Solaris/Illumos requires a wrapper around log, log2, and log10 functions
930
- // because of their non-standard behavior (e.g., log(-n) returns -Inf instead
931
- // of expected NaN).
932
- #[ rustc_allow_incoherent_impl]
933
- fn log_wrapper < F : Fn ( f64 ) -> f64 > ( self , log_fn : F ) -> f64 {
934
- if let Some ( result) = crate :: sys:: log_wrapper ( self ) {
935
- log_fn ( result)
936
- } else if self . is_finite ( ) {
937
- if self > 0.0 {
938
- log_fn ( self )
939
- } else if self == 0.0 {
940
- Self :: NEG_INFINITY // log(0) = -Inf
941
- } else {
942
- Self :: NAN // log(-n) = NaN
943
- }
944
- } else if self . is_nan ( ) {
945
- self // log(NaN) = NaN
946
- } else if self > 0.0 {
947
- self // log(Inf) = Inf
948
- } else {
949
- Self :: NAN // log(-Inf) = NaN
950
- }
951
- }
952
928
}
0 commit comments