-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Decimal parsing ignores significant digits below 1e-49 #375
Comments
This is indeed a bug. Roslyn uses the function decimal.TryParse from BCL to parse decimal literals. There is a bug in that function (BCL team is aware of it, but AFAIK their current plan is not to fix it for back compat reasons). If we stop using decimal.TryParse and implement correct parsing of decimal literals in Roslyn, it would cause behavior in compile-time and runtime to be different. |
That is not probably sufficient by itself to justify implementing IEEE 754-2008 and introducing decimal32, decimal64 and decimal128, but perhaps another small reason to start looking at the successor of decimal? Those can now be found in Intel C++ compiler, gcc, SAP, and progressing on the C and C++ language tracks for instance. Independently of the added 5-6 significant digits of decimal128 and the optimizations possible with the 64 and 32 bit formats, which have some applications, using a standard representation will eventually avoid a lot of cross-platform headaches. |
@codespare You're welcome to create a new issue proposing that if you think it is worth our effort. |
It undoubtedly would be at some point after 1.0 in my opinion, so I will certainly give a try at starting to document it as it deserves. I also recently came across a related issue, with the BCL project if my memory is correct, proposing to add some of the additional functions defined in IEEE 754-2008 for float and double. Regarding the issue at hand, I believe it could be tracing back to https://github.com/dotnet/coreclr/blob/master/src/classlibnative/bcltype/decimal.cpp#L350 , although it is more an inference at this stage as I haven't gone through BCL ParseDecimal. |
See #372 (comment) ; this is now fixed in the BCL. |
Assigning to myself to add a test confirming this is fixed in the BCL that Roslyn runs against. |
…als correctly Fixes dotnet#375
See
CodeGenTests.DecimalLiteral_BreakingChange
unit test.Compile and Run:
Expected:
0.0000000000000000000000000001
0.0000000000000000000000000001
Actual:
0.0000000000000000000000000001
0.0000000000000000000000000000
[ported from TFS DevDiv 568494]
@cston @VladimirReshetnikov
The text was updated successfully, but these errors were encountered: