-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Add Decimal32, Decimal64, Decimal128 #100729
base: main
Are you sure you want to change the base?
Conversation
Note regarding the
|
src/libraries/System.Private.CoreLib/src/System/Number.Parsing.cs
Outdated
Show resolved
Hide resolved
static int IDecimalIeee754UnpackInfo<Decimal128, Int128, UInt128>.NumberDigitsPrecision => NumberDigitsPrecision; | ||
|
||
|
||
private static Int128[] Int128Powers10 => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Int128 is not optimized, this can be optimally stored as a ReadOnlySpan of Int32/Int64 like Number.BigInteger.Pow10BigNumTable
public override int GetHashCode() | ||
{ | ||
return _value.GetHashCode(); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+0 and -0 should have the same hash code. The easiest way can be stripping the sign bit.
I also remember that there can be same values with different representations.
runtime/src/libraries/System.Private.CoreLib/src/System/Numerics/TotalOrderIeee754Comparer.cs
Lines 125 to 132 in 9b57a26
else | |
{ | |
// Equivalant values are compared by their exponent parts, | |
// and the value with smaller exponent is considered closer to zero. | |
// This only applies to IEEE 754 decimals. Consider to add support if decimals are added into .NET. | |
return 0; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@huoyaoyuan Thanks for your review. However this PR targets only the first phase as following: #81376 (comment) so I haven't added NegativeZero
and PositiveZero
. I will update GetHashCode
method in the next phase.
src/libraries/System.Private.CoreLib/src/System/Numerics/Decimal128.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.DecimalIeee754.cs
Outdated
Show resolved
Hide resolved
This is on my radar to take a look at; just noting it might be a bit delayed due to other priorities for the .NET 9 release. CC. @jeffhandley |
sorry for being picky - the last two commits have titles that don't really match the contents, it could be improved (for traceability's sake) |
Hi @tannergooding, I'm just curious when this PR can be reviewed ? 😄 |
Maybe after feature complete of .NET 9. As the original API review, this API is out of scope for .NET 9, as well as |
As huoyaoyuan indicated I would expect to get to this in early .NET 10 at this point in time (there's only around 10 more days before the next snap, at which point we start locking down for RC1). I really appreciate the effort put into this and the drive to try and get it in, it just wasn't part of the "scheduled" work for .NET 9 and so continued to be deprioritized in comparison to the other feature work going on in the numerics space (mostly due to the size/complexity involved here). I do still intend to drive this in and will do my best to ensure this is included as part of the scheduled work for .NET 10. |
I should be getting to this soon. .NET 9 shipped last week and I'm slowly getting through the set of PRs that had been opened and got pushed out for .NET 10. This is itself a slightly larger and more complicated PR so it started closer to the bottom of my backlog; but it is getting much closer to a point where I can sit down and get it review. Appreciate everyone's patience here and I am (like many others) looking forward to getting this in finally 😄 |
I seem to recall seeing an upcoming PR that would create a Decimal type with |
@masonwheeler that’d be covered by the total #81376 issue this or is really just the first step, getting the base types defined and out, which will then allow incremental exposure of the full set of math APIs |
Copilot
AI
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 5 out of 14 changed files in this pull request and generated 4 comments.
Files not reviewed (9)
- src/libraries/System.Private.CoreLib/src/Resources/Strings.resx: Language not supported
- src/libraries/System.Private.CoreLib/src/System.Private.CoreLib.Shared.projitems: Language not supported
- src/libraries/System.Runtime/tests/System.Runtime.Tests/System.Runtime.Tests.csproj: Language not supported
- src/libraries/System.Runtime/ref/System.Runtime.cs: Evaluated as low risk
- src/libraries/Common/src/System/Number.NumberBuffer.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/Numerics/Decimal128.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/Number.Formatting.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/Number.Parsing.cs: Evaluated as low risk
- src/libraries/System.Private.CoreLib/src/System/Numerics/Decimal32.cs: Evaluated as low risk
Comments suppressed due to low confidence (3)
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Decimal32Tests.cs:223
- The test case 'Midpoint_Rounding' does not adequately cover different rounding scenarios. Consider adding more test cases to cover various rounding edge cases.
public static void Midpoint_Rounding()
src/libraries/System.Runtime/tests/System.Runtime.Tests/System/Decimal32Tests.cs:230
- The test case 'Rounding' does not adequately cover different rounding scenarios. Consider adding more test cases to cover various rounding edge cases.
public static void Rounding()
src/libraries/System.Private.CoreLib/src/System/Numerics/Decimal64.cs:58
- The property name
Int64Powers10
is not consistent with the naming conventions. Consider renaming it toInt64PowersOf10
for clarity.
private static ReadOnlySpan<long> Int64Powers10 =>
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
src/libraries/System.Private.CoreLib/src/System/Number.DecimalIeee754.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.DecimalIeee754.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.DecimalIeee754.cs
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/Number.DecimalIeee754.cs
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Resolve #81376