Skip to content

Consider adding SingleToUInt32Bits(float value) to BitConverter #36469

@pgovind

Description

@pgovind

BitConverter has APIs to convert float -> int, but not uint. Sometimes it's useful to get the uint bits underlying a float too (for ex: I'd find it useful for #936).

API:

public static unsafe ulong DoubleToUInt64Bits(double value);
public static unsafe double UInt64BitsToDouble(ulong value)

public static unsafe ushort HalfToUInt16Bits(Half value);
public static unsafe Half UInt16BitsToHalf(ushort value)

public static unsafe uint SingleToUInt32Bits(float value);
public static unsafe float UInt32BitsToSingle(uint value)

Note: uint is not CLS compliant

cc @tannergooding

Metadata

Metadata

Assignees

No one assigned

    Labels

    api-approvedAPI was approved in API review, it can be implementedarea-System.Numericshelp wanted[up-for-grabs] Good issue for external contributors

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions