Skip to content

Commit 1e7bacd

Browse files
authored
Document powf and powi values that are always 1.0
f64 part for bug #90429
1 parent 8231e85 commit 1e7bacd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

library/std/src/f64.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ impl f64 {
306306
/// ```
307307
/// let x = 2.0_f64;
308308
/// let abs_difference = (x.powi(2) - (x * x)).abs();
309-
///
310309
/// assert!(abs_difference < 1e-10);
310+
///
311+
/// assert_eq!(f64::powi(f64::NAN, 0), 1.0);
311312
/// ```
312313
#[rustc_allow_incoherent_impl]
313314
#[must_use = "method returns a new number and does not mutate the original value"]
@@ -329,8 +330,10 @@ impl f64 {
329330
/// ```
330331
/// let x = 2.0_f64;
331332
/// let abs_difference = (x.powf(2.0) - (x * x)).abs();
332-
///
333333
/// assert!(abs_difference < 1e-10);
334+
///
335+
/// assert_eq!(f64::powf(1.0, f64::NAN), 1.0)
336+
/// assert_eq!(f64::powf(f64::NAN, 0.0), 1.0)
334337
/// ```
335338
#[rustc_allow_incoherent_impl]
336339
#[must_use = "method returns a new number and does not mutate the original value"]

0 commit comments

Comments
 (0)