Skip to content
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

Denormal floating-point constants #11135

Closed
HertzDevil opened this issue Aug 25, 2021 · 0 comments · Fixed by #13961
Closed

Denormal floating-point constants #11135

HertzDevil opened this issue Aug 25, 2021 · 0 comments · Fixed by #13961

Comments

@HertzDevil
Copy link
Contributor

Float64::MIN_POSITIVE is the "Smallest representable positive value" for Float64, and similarly for Float32:

struct Float64
  # Smallest representable positive value
  MIN_POSITIVE = 2.2250738585072014e-308_f64
end

But this is inaccurate because MIN_POSITIVE is the smallest normal floating-point value; there are 2 ** 52 - 1 denormal floats smaller than that, and all of them do represent exact values, the smallest of which admits any of the following equivalent definitions:

5.0e-324_f64
0.0_f64.next_float
1_u64.unsafe_as(Float64)

Or, for Float32:

1.0e-45_f32
0.0_f32.next_float
1_u32.unsafe_as(Float32)

I suggest we add these constants as MIN_DENORMAL, and then adjust MIN_POSITIVE's docs accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant