@@ -468,6 +468,8 @@ impl f128 {
468
468
469
469
/// Returns the natural logarithm of the number.
470
470
///
471
+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
472
+ ///
471
473
/// # Unspecified precision
472
474
///
473
475
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -489,6 +491,16 @@ impl f128 {
489
491
/// assert!(abs_difference <= f128::EPSILON);
490
492
/// # }
491
493
/// ```
494
+ ///
495
+ /// Non-positive values:
496
+ /// ```
497
+ /// #![feature(f128)]
498
+ /// # #[cfg(reliable_f128_math)] {
499
+ ///
500
+ /// assert_eq!(0_f128.ln(), f128::NEG_INFINITY);
501
+ /// assert!((-42_f128).ln().is_nan());
502
+ /// # }
503
+ /// ```
492
504
#[ inline]
493
505
#[ rustc_allow_incoherent_impl]
494
506
#[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -499,6 +511,8 @@ impl f128 {
499
511
500
512
/// Returns the logarithm of the number with respect to an arbitrary base.
501
513
///
514
+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
515
+ ///
502
516
/// The result might not be correctly rounded owing to implementation details;
503
517
/// `self.log2()` can produce more accurate results for base 2, and
504
518
/// `self.log10()` can produce more accurate results for base 10.
@@ -522,6 +536,16 @@ impl f128 {
522
536
/// assert!(abs_difference <= f128::EPSILON);
523
537
/// # }
524
538
/// ```
539
+ ///
540
+ /// Non-positive values:
541
+ /// ```
542
+ /// #![feature(f128)]
543
+ /// # #[cfg(reliable_f128_math)] {
544
+ ///
545
+ /// assert_eq!(0_f128.log(10.0), f128::NEG_INFINITY);
546
+ /// assert!((-42_f128).log(10.0).is_nan());
547
+ /// # }
548
+ /// ```
525
549
#[ inline]
526
550
#[ rustc_allow_incoherent_impl]
527
551
#[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -532,6 +556,8 @@ impl f128 {
532
556
533
557
/// Returns the base 2 logarithm of the number.
534
558
///
559
+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
560
+ ///
535
561
/// # Unspecified precision
536
562
///
537
563
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -551,6 +577,16 @@ impl f128 {
551
577
/// assert!(abs_difference <= f128::EPSILON);
552
578
/// # }
553
579
/// ```
580
+ ///
581
+ /// Non-positive values:
582
+ /// ```
583
+ /// #![feature(f128)]
584
+ /// # #[cfg(reliable_f128_math)] {
585
+ ///
586
+ /// assert_eq!(0_f128.log2(), f128::NEG_INFINITY);
587
+ /// assert!((-42_f128).log2().is_nan());
588
+ /// # }
589
+ /// ```
554
590
#[ inline]
555
591
#[ rustc_allow_incoherent_impl]
556
592
#[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -561,6 +597,8 @@ impl f128 {
561
597
562
598
/// Returns the base 10 logarithm of the number.
563
599
///
600
+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
601
+ ///
564
602
/// # Unspecified precision
565
603
///
566
604
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -580,6 +618,16 @@ impl f128 {
580
618
/// assert!(abs_difference <= f128::EPSILON);
581
619
/// # }
582
620
/// ```
621
+ ///
622
+ /// Non-positive values:
623
+ /// ```
624
+ /// #![feature(f128)]
625
+ /// # #[cfg(reliable_f128_math)] {
626
+ ///
627
+ /// assert_eq!(0_f128.log10(), f128::NEG_INFINITY);
628
+ /// assert!((-42_f128).log10().is_nan());
629
+ /// # }
630
+ /// ```
583
631
#[ inline]
584
632
#[ rustc_allow_incoherent_impl]
585
633
#[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -966,6 +1014,8 @@ impl f128 {
966
1014
/// Returns `ln(1+n)` (natural logarithm) more accurately than if
967
1015
/// the operations were performed separately.
968
1016
///
1017
+ /// This returns NaN when `n < -1.0`, and negative infinity when `n == -1.0`.
1018
+ ///
969
1019
/// # Unspecified precision
970
1020
///
971
1021
/// The precision of this function is non-deterministic. This means it varies by platform,
@@ -989,6 +1039,16 @@ impl f128 {
989
1039
/// assert!(abs_difference < 1e-10);
990
1040
/// # }
991
1041
/// ```
1042
+ ///
1043
+ /// Out-of-range values:
1044
+ /// ```
1045
+ /// #![feature(f128)]
1046
+ /// # #[cfg(reliable_f128_math)] {
1047
+ ///
1048
+ /// assert_eq!((-1.0_f128).ln_1p(), f128::NEG_INFINITY);
1049
+ /// assert!((-2.0_f128).ln_1p().is_nan());
1050
+ /// # }
1051
+ /// ```
992
1052
#[ inline]
993
1053
#[ doc( alias = "log1p" ) ]
994
1054
#[ must_use = "method returns a new number and does not mutate the original value" ]
0 commit comments