Skip to content

Commit 634564a

Browse files
authored
Document powf and powi values that are always 1.0 (f128)
f128 part for bug rust-lang#90429
1 parent 8231e85 commit 634564a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

library/std/src/f128.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,16 @@ impl f128 {
324324
///
325325
/// The precision of this function is non-deterministic. This means it varies by platform,
326326
/// Rust version, and can even differ within the same execution from one invocation to the next.
327+
///
328+
/// # Examples
329+
///
330+
/// ```
331+
/// let x = 2.0_f128;
332+
/// let abs_difference = (x.powi(2) - (x * x)).abs();
333+
/// assert!(abs_difference < f128::EPSILON);
334+
///
335+
/// assert_eq!(f128::powi(f128::NAN, 0), 1.0);
336+
/// ```
327337
#[inline]
328338
#[rustc_allow_incoherent_impl]
329339
#[unstable(feature = "f128", issue = "116909")]
@@ -347,8 +357,10 @@ impl f128 {
347357
///
348358
/// let x = 2.0_f128;
349359
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
350-
///
351360
/// assert!(abs_difference <= f128::EPSILON);
361+
///
362+
/// assert_eq!(f128::powf(1.0, f128::NAN), 1.0)
363+
/// assert_eq!(f128::powf(f128::NAN, 0.0), 1.0)
352364
/// # }
353365
/// ```
354366
#[inline]

0 commit comments

Comments
 (0)