f32 and f64 powf NaN handling should be documented · Issue #90429 · rust-lang/rust (original) (raw)

The f32 and f64 powf methods follow the IEEE 754-2008 recommendations for NaN handling, but these are quite surprising. For example, f64::powf(1.0, f64::NAN) returns 1.0, not f64::NAN. This behavior should be documented.

The current docs don't mention NaN at all, which leads one to assume that any argument being NaN would produce a NaN result, like arithmetic operations. But these are not the standard behavior for powf.

This was mentioned in #60468, which links a playground illustrating the exceptions.