dotnet / docs

This repository contains .NET Documentation.
https://learn.microsoft.com/dotnet
Creative Commons Attribution 4.0 International
4.21k stars 5.86k forks source link

Clarify that System.Decimal is not IEEE-754 compliant in documentation #33523

Open yretenai opened 1 year ago

yretenai commented 1 year ago

Issue description

Neither the reference docs or the decimal docs point out that the decimal type is not a binary128 or decimal128 value despite being listed among binary32 and binary64 values.

This is evident when we look at the representation of 1.0 in different 128-bit floating point formats (in little endian.)

Note that the last 2 bytes of decimal128 are different. Parsing the decimal128 value into System.Decimal either through GetBits or Memory casting will fail the IsValid() check (indicating it's not a Win32 DECIMAL.)

Since decimal128 and binary128 are standardized in the 2008 revision of the IEEE-754 format, this can lead to confusion when referring to decimal128 values (as System.Decimal is not an IEEE decimal float despite being a decimal floating point value.)


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

BillWagner commented 1 year ago

ping @tannergooding for a recommendation on the best fix.