Closed sachincholkar closed 2 weeks ago
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.
Tagging subscribers to this area: @dotnet/area-system-runtime
This is how its always behaved and it matches how the underlying Win32 DECIMAL
type on which this is based behaves as well.
In general you can compare the decimal
behavior with the underlying VarDec*
function (VarDecMul
in this case) and we are expected to match that behavior.
In this case, the underlying native implementation does not preserve trailing zeros in all cases and there is, AFAIK, no guarantee of that in any documentation. The managed implementation of this function is here: https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/Decimal.DecCalc.cs,04f3e28ca99259ec
This issue has been marked needs-author-action
and might be missing some important information.
This issue has been automatically closed due to no response from the original author. Feel free to reopen it if you have more information that can help us investigate the issue further.
Type of issue
Code doesn't work
Description
//Code result = 0 decimal price = 0m; decimal valUnits = 4295.000000m; Console.WriteLine(Decimal.Multiply(price, valUnits));
//Code result = 0.000000 decimal price = 0m; decimal valUnits = 4294.000000m; Console.WriteLine(Decimal.Multiply(price, valUnits));
//Code result = 0.000000 decimal price = 0m; decimal valUnits = 4295.00000m; //reduced decimal places to 5 Console.WriteLine(Decimal.Multiply(price, valUnits));
when working with decimal types, expectation is for result decimal to preserve the decimal zeros. Even if the result is 0, then it should be common for all the results. Between 4294.000000 & 4295.000000, the binary values don't change significantly except for the lowest bit.
Page URL
https://learn.microsoft.com/en-us/dotnet/api/system.decimal.multiply?view=net-8.0#system-decimal-multiply(system-decimal-system-decimal)
Content source URL
https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System/Decimal.xml
Document Version Independent Id
4ec1f71e-31ee-e91a-5126-48b16ef44812
Article author
@dotnet-bot