Skip to content

fix MAX_EXP and MIN_EXP docs #140150

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 24, 2025
Merged

fix MAX_EXP and MIN_EXP docs #140150

merged 1 commit into from
Apr 24, 2025

Conversation

RalfJung
Copy link
Member

As pointed out in #88734, the docs for these constants are wrong.

r? @tgross35

@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 Apr 22, 2025
@tgross35
Copy link
Contributor

Maybe it's worth adding something like "... for a significand bounded by 1 <= x < 2 (the IEEE definition), or the maximum power of 2 for a significand bounded by 0.5 <= x < 1 (the C definition)."? To make it sound a bit less like we just picked the wrong number... which maybe we did 🙃

@@ -200,7 +200,7 @@ impl f128 {
/// ≥&nbsp;0.5&nbsp;×&nbsp;2<sup><i>x</i></sup>.
#[unstable(feature = "f128", issue = "116909")]
pub const MIN_EXP: i32 = -16_381;
/// Maximum possible power of 2 exponent.
/// One greater than the maximum possible power of 2 exponent.
///
/// If <i>x</i>&nbsp;=&nbsp;`MAX_EXP`, then normal numbers
/// &lt;&nbsp;1&nbsp;×&nbsp;2<sup><i>x</i></sup>.
Copy link
Member Author

Choose a reason for hiding this comment

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

Why do we even have this sentence about normal numbers here? Unlike for MIN_EXP, normal numbers are not mentioned in the definition of this constant.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, it looks like this here actually uses the C definition of "exponent"?

Copy link
Contributor

Choose a reason for hiding this comment

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

Wow that is HTML is impossible to read, we should add the rustdoc katex/temml plugin or something. Yeah that mention of normals is probably copy+paste.

I guess we could just add a note that the 0.5 <= x < 1 isn't necessarially the definition that one would expect.

Copy link
Member Author

Choose a reason for hiding this comment

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

I guess we could just add a note that the 0.5 <= x < 1 isn't necessarially the definition that one would expect.

We now just spell out both definitions, not sure what else there would be to add here? If you want the wording to be changed/extended, please make a concrete suggestion.

@RalfJung
Copy link
Member Author

I have updated the docs for f128, please have a look before I copy-paste this to all the other types.

@RalfJung RalfJung changed the title fix MAX_EXP docs fix MAX_EXP and MIN_EXP docs Apr 22, 2025
Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

r=me but I think there should be an extra line break after "(i.e. the IEEE definition)." to keep the summary down to one sentence.

@RalfJung
Copy link
Member Author

Like so?

@tgross35
Copy link
Contributor

Thanks, I just know rustdoc and RLA start to look weird when summaries are longer than 1-2 lines in source.

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Apr 23, 2025

📌 Commit 157caee has been approved by tgross35

It is now in the queue for this repository.

@bors bors 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 Apr 23, 2025
Zalathar added a commit to Zalathar/rust that referenced this pull request Apr 24, 2025
fix MAX_EXP and MIN_EXP docs

As pointed out in rust-lang#88734, the docs for these constants are wrong.

r? `@tgross35`
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2025
Rollup of 23 pull requests

Successful merges:

 - rust-lang#139261 (mitigate MSVC alignment issue on x86-32)
 - rust-lang#139307 (std: Add performance warnings to HashMap::get_disjoint_mut)
 - rust-lang#139700 (Autodiff flags)
 - rust-lang#139752 (set subsections_via_symbols for ld64 helper sections)
 - rust-lang#139809 (Don't warn about `v128` in wasm ABI transition)
 - rust-lang#139852 (StableMIR: Implement `CompilerInterface`)
 - rust-lang#139945 (Extend HIR to track the source and syntax of a lifetime)
 - rust-lang#140028 (`deref_patterns`: support string and byte string literals in explicit `deref!("...")` patterns)
 - rust-lang#140139 (rustc_target: Adjust RISC-V feature implication)
 - rust-lang#140143 (Move `sys::pal::os::Env` into `sys::env`)
 - rust-lang#140148 (CI: use aws codebuild for job dist-arm-linux)
 - rust-lang#140150 (fix MAX_EXP and MIN_EXP docs)
 - rust-lang#140172 (Make algebraic functions into `const fn` items.)
 - rust-lang#140177 ([compiletest] Parallelize test discovery)
 - rust-lang#140181 (Remove `synstructure::Structure::underscore_const` calls.)
 - rust-lang#140184 (Update doc of cygwin target)
 - rust-lang#140186 (Rename `compute_x` methods)
 - rust-lang#140187 ([AIX] Handle AIX dynamic library extensions within c-link-to-rust-dylib run-make test)
 - rust-lang#140191 (Remove git repository from git config)
 - rust-lang#140194 (minicore: Have `//@ add-core-stubs` also imply `-Cforce-unwind-tables=yes`)
 - rust-lang#140195 (triagebot: label minicore changes w/ `A-test-infra-minicore` and ping jieyouxu on changes)
 - rust-lang#140202 (Make #![feature(let_chains)] bootstrap conditional in compiler/)
 - rust-lang#140214 (Remove comment about handling non-global where bounds with corresponding projection)

r? `@ghost`
`@rustbot` modify labels: rollup
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2025
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#136083 (Suggest {to,from}_ne_bytes for transmutations between arrays and integers, etc)
 - rust-lang#138282 (Add `#[repr(u128)]`/`#[repr(i128)]` enums to `improper_ctypes_definitions`)
 - rust-lang#139700 (Autodiff flags)
 - rust-lang#140139 (rustc_target: Adjust RISC-V feature implication)
 - rust-lang#140141 (Move zkVM constants into `sys::env_consts`)
 - rust-lang#140150 (fix MAX_EXP and MIN_EXP docs)
 - rust-lang#140172 (Make algebraic functions into `const fn` items.)
 - rust-lang#140191 (Remove git repository from git config)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 06126df into rust-lang:master Apr 24, 2025
6 checks passed
@rustbot rustbot added this to the 1.88.0 milestone Apr 24, 2025
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 24, 2025
Rollup merge of rust-lang#140150 - RalfJung:MAX_EXP, r=tgross35

fix MAX_EXP and MIN_EXP docs

As pointed out in rust-lang#88734, the docs for these constants are wrong.

r? ``@tgross35``
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