Skip to content

[ER] const from_bits/to_bits for f32/f64 #73736

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

Closed
leonardo-m opened this issue Jun 25, 2020 · 2 comments
Closed

[ER] const from_bits/to_bits for f32/f64 #73736

leonardo-m opened this issue Jun 25, 2020 · 2 comments
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

This is an enhancement request. I'd like u32::from_bits, u64::from_bits, and f32::to_bits, f64::to_bits usable in const functions. I think today they can be implemented using const_transmute:

#![feature(const_transmute)]
const fn from_bits(v: u32) -> f32 {
    unsafe { std::mem::transmute(v) }
}
const fn to_bits(v: f32) -> u32 {
    unsafe { std::mem::transmute(v) }
}
fn main() {}
@LeSeulArtichaut LeSeulArtichaut added A-const-fn C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Jun 26, 2020
@Ryan1729
Copy link
Contributor

Making two_bits and from_bits usable in const functions was also mentioned as an aside in #57241

@Dylan-DPC
Copy link
Member

Closing this as it will be covered by #57241

@Dylan-DPC Dylan-DPC closed this as not planned Won't fix, can't repro, duplicate, stale Dec 27, 2023
@RalfJung RalfJung added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

5 participants