{"action":"opened","issue":{"url":"https://api.github.com/repos/dotnet/corefx/issues/4673","labels_url":"https://api.github.com/repos/dotnet/corefx/issues/4673/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/corefx/issues/4673/comments","events_url":"https://api.github.com/repos/dotnet/corefx/issues/4673/events","html_url":"https://github.com/dotnet/corefx/issues/4673","id":118901556,"number":4673,"title":"Add: BitConverter.SingleToInt32Bits and Int32BitsToSingle","user":{"login":"AlexGhiondea","id":8396979,"avatar_url":"https://avatars.githubusercontent.com/u/8396979?v=3","gravatar_id":"","url":"https://api.github.com/users/AlexGhiondea","html_url":"https://github.com/AlexGhiondea","followers_url":"https://api.github.com/users/AlexGhiondea/followers","following_url":"https://api.github.com/users/AlexGhiondea/following{/other_user}","gists_url":"https://api.github.com/users/AlexGhiondea/gists{/gist_id}","starred_url":"https://api.github.com/users/AlexGhiondea/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AlexGhiondea/subscriptions","organizations_url":"https://api.github.com/users/AlexGhiondea/orgs","repos_url":"https://api.github.com/users/AlexGhiondea/repos","events_url":"https://api.github.com/users/AlexGhiondea/events{/privacy}","received_events_url":"https://api.github.com/users/AlexGhiondea/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2015-11-25T18:58:07Z","updated_at":"2015-11-25T18:58:07Z","closed_at":null,"body":"To match the existing `DoubleToInt64Bits` and `Int64BitsToDouble`. This is important for binary serialization tools to get hold of the underlying value without requiring unsafe themselves, which may not be accepted.\r\n\r\nExample usage: IO / sockets tools, raw protocol tools, network libraries, serialization tools.\r\n\r\n## Existing 64-bit API\r\n\r\n    public static long BitConverter.DoubleToInt64Bits(double value);\r\n    public static double BitConverter.Int64BitsToDouble(long value);\r\n\r\nHowever, no 32-bit api exists\r\n\r\n## Proposed 32-bit API\r\n\r\nTo mimic existing API:\r\n\r\n    public static int BitConverter.SingleToInt32Bits(float value);\r\n    public static float BitConverter.Int32BitsToSingle(int value);\r\n\r\n## Rationale and Usage\r\n\r\nExactly the same as pre-existing 64-bit API:\r\n\r\n- caller can populate an `int` (perhaps via shift ops and network access / stream, perhaps via raw memory access), and force it to a `float`, for example during deserialization\r\n- caller can consume a `float` and force it to an `int` (perhaps for use on network access / stream via shift, perhaps via raw memory access), for example during serialization\r\n\r\n## Details\r\n\r\nTo follow same rules and conventions as the existing 64-bit api, which is to say: uses straight unsafe cast - does not explicitly consider machines where integer and floating-point endianness are different (integer big-endian, floating-point little-endian), but is fine on both big-endian and little-endian machines - in reality the endianness matches. To emphasise: there is nothing in here that is different from the expectations of the existing 64-bit api. It would be inconsistent to have the 32-bit API operate with different expectations to the 64-bit api, and it would be a breaking change to alter the expectations of the existing 64-bit api.\r\n\r\n## Pull Request\r\n\r\nA pull request is available with the proposed implementation (comments etc based on the existing 64-bit API): https://github.com/dotnet/coreclr/pull/833\r\n\r\n## Issues\r\n\r\nNone known; not a breaking change, and no overload resolution issue since uniquely named static non-extension methods.\r\n\r\n## Discussion Point\r\n\r\nPossible doubt over relevancy of comments and assertion. This is addressed separately in https://github.com/dotnet/coreclr/issues/834"}}