@@ -468,6 +468,8 @@ impl f128 {
468468
469469 /// Returns the natural logarithm of the number.
470470 ///
471+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
472+ ///
471473 /// # Unspecified precision
472474 ///
473475 /// The precision of this function is non-deterministic. This means it varies by platform,
@@ -489,6 +491,16 @@ impl f128 {
489491 /// assert!(abs_difference <= f128::EPSILON);
490492 /// # }
491493 /// ```
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+ /// ```
492504 #[ inline]
493505 #[ rustc_allow_incoherent_impl]
494506 #[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -499,6 +511,8 @@ impl f128 {
499511
500512 /// Returns the logarithm of the number with respect to an arbitrary base.
501513 ///
514+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
515+ ///
502516 /// The result might not be correctly rounded owing to implementation details;
503517 /// `self.log2()` can produce more accurate results for base 2, and
504518 /// `self.log10()` can produce more accurate results for base 10.
@@ -522,6 +536,16 @@ impl f128 {
522536 /// assert!(abs_difference <= f128::EPSILON);
523537 /// # }
524538 /// ```
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+ /// ```
525549 #[ inline]
526550 #[ rustc_allow_incoherent_impl]
527551 #[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -532,6 +556,8 @@ impl f128 {
532556
533557 /// Returns the base 2 logarithm of the number.
534558 ///
559+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
560+ ///
535561 /// # Unspecified precision
536562 ///
537563 /// The precision of this function is non-deterministic. This means it varies by platform,
@@ -551,6 +577,16 @@ impl f128 {
551577 /// assert!(abs_difference <= f128::EPSILON);
552578 /// # }
553579 /// ```
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+ /// ```
554590 #[ inline]
555591 #[ rustc_allow_incoherent_impl]
556592 #[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -561,6 +597,8 @@ impl f128 {
561597
562598 /// Returns the base 10 logarithm of the number.
563599 ///
600+ /// This returns NaN when the number is negative, and negative infinity when number is zero.
601+ ///
564602 /// # Unspecified precision
565603 ///
566604 /// The precision of this function is non-deterministic. This means it varies by platform,
@@ -580,6 +618,16 @@ impl f128 {
580618 /// assert!(abs_difference <= f128::EPSILON);
581619 /// # }
582620 /// ```
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+ /// ```
583631 #[ inline]
584632 #[ rustc_allow_incoherent_impl]
585633 #[ unstable( feature = "f128" , issue = "116909" ) ]
@@ -966,6 +1014,8 @@ impl f128 {
9661014 /// Returns `ln(1+n)` (natural logarithm) more accurately than if
9671015 /// the operations were performed separately.
9681016 ///
1017+ /// This returns NaN when `n < -1.0`, and negative infinity when `n == -1.0`.
1018+ ///
9691019 /// # Unspecified precision
9701020 ///
9711021 /// The precision of this function is non-deterministic. This means it varies by platform,
@@ -989,6 +1039,16 @@ impl f128 {
9891039 /// assert!(abs_difference < 1e-10);
9901040 /// # }
9911041 /// ```
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+ /// ```
9921052 #[ inline]
9931053 #[ doc( alias = "log1p" ) ]
9941054 #[ must_use = "method returns a new number and does not mutate the original value" ]
0 commit comments