Skip to content

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

Closed as not planned
Closed as not planned
@leonardo-m

Description

@leonardo-m

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() {}

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-feature-requestCategory: A feature request, i.e: not implemented / a PR.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