rust-lang / rust-lang/rust

Tracking Issue for `float_exact_integer_constants`

Open
#152,466 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue T-libs
Dominant language
Rust
Stars
119k
Forks
16.2k
PR merge metrics
PR metrics pending

Description

Feature gate: #![feature(float_exact_integer_constants)]

This is a tracking issue for integer constants that represent the range of consecutive values that can be losslessly round-tripped to and from the corresponding floating point type. Additionally, integers within this range will convert to a floating point value that no other integer will convert to.

Public API

These constants are defined as ±(2mantissa_digits-1).

impl fN {
    pub const MAX_EXACT_INTEGER: iN = (1 << Self::MANTISSA_DIGITS) - 1;
    pub const MIN_EXACT_INTEGER: iN = -MAX_EXACT_INTEGER;
}
Steps / History
Unresolved Questions
  • Naming: If a better name comes up, it can be changed. MAX_EXACT_INTEGER was determined to be the best compromise of suggested names. https://github.com/rust-lang/libs-team/issues/713#issuecomment-3880122239:
    Based on the options we've seen, we feel like MAX_EXACT_INTEGER is a good balance between clarity and brevity. It does still have the property that one could interpret it as allowing one integer larger because that integer's truncated low bit would be 0, but we felt like any name trying to capture that property (and make it clear that the correct value is one less than the appropriate power of two) would be sufficiently verbose as to be less clear.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Review the linked implementation PR #152512 and the ACP in libs-team issue #713 first. Then follow the stabilization process in the referenced Feature Lifecycle guide; this issue is done when the final comment period and stabilization PR are complete.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.