Skip to content

core/num: Implement feature float_nan_to - #161250

Open
okaneco wants to merge 1 commit into
rust-lang:mainfrom
okaneco:nan_to
Open

core/num: Implement feature float_nan_to#161250
okaneco wants to merge 1 commit into
rust-lang:mainfrom
okaneco:nan_to

Conversation

@okaneco

@okaneco okaneco commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

Accepted ACP: rust-lang/libs-team#787
Tracking issue: #161248

Add function nan_to on f16, f32, f64, f128 which replaces NaN values with a user-specified value or returns the original value if it is not a NaN.


No LLM use.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 17, 2026
@rust-log-analyzer

This comment has been minimized.

Comment thread library/core/src/num/f128.rs Outdated
Comment on lines +1606 to +1607
/// Returns `self` if the value is a number, otherwise returns `replacement`
/// if `self` is NaN.

@clarfonthey clarfonthey Aug 17, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer the wording: "is not NaN" even though "number" feels like the right choice for the opposite of "not a number", since we use the term "number" across the rest of the float docs to just mean any float.

Also, "number" could be misinterpreted to exclude all non-finite values even though explicitly NaN is excluded.

View changes since the review

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, coming up with phrasing in line with the style of the rest of the docs was awkward.

Addressed in latest commit.

@clarfonthey

Copy link
Copy Markdown
Contributor

Minor docs nit, otherwise looks good to me.

Add function `nan_to` on floats which replaces NaN values with a
user-specified value or returns the original value if it is not a NaN.
@clarfonthey

Copy link
Copy Markdown
Contributor

Looks good, thank you!

@bors r+ rollup

@rust-bors

rust-bors Bot commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 9755e31 has been approved by clarfonthey

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 17, 2026
jhpratt added a commit to jhpratt/rust that referenced this pull request Aug 18, 2026
core/num: Implement feature `float_nan_to`

Accepted ACP: rust-lang/libs-team#787
Tracking issue: rust-lang#161248

Add function `nan_to` on `f16`, `f32`, `f64`, `f128` which replaces NaN values with a user-specified value or returns the original value if it is not a NaN.

---

No LLM use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants