Skip to content

Tracking Issue for float_exact_integer_constants #152466

@okaneco

Description

@okaneco

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. ACP: Add float constants for min/max limits of consecutive integers that convert to unique floats libs-team#713 (comment):
    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.

Footnotes

  1. https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCS-tracking-unimplementedStatus: The feature has not been implemented.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions