Skip to content

Endianness comments in BitConverter.DoubleToInt32Bits and Int32BitsToDouble are irrelevant #4184

@sharwell

Description

@sharwell

Similar to the comments highlighted in dotnet/coreclr#833, the BitConverter.DoubleToInt32Bits and Int32BitsToDouble methods contain endianness comments which are almost certainly irrelevant.

  • The .NET Framework doesn't support, and is unlikely to ever support, any architecture which uses a different endianness for its internal representation of integers and floating-point numbers.
  • The current implementation of this method does already work on both little- and big-endian machines, provided the Contract.Assert call is not there.

I recommend these comments as well as the calls to Contract.Assert be removed, and the documentation updated to explicitly include the following text (or an equivalent variant) stating a precondition that has always existed but was previously undocumented.

This method assumes the hardward uses the same endianness for integers and floating-point numbers.

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wanted[up-for-grabs] Good issue for external contributors

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions