-
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 System.Math API overloads for nint/nuint #43733
Comments
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. |
Looking at the other APIs, there is also:
I don't think |
Tagging subscribers to this area: @tannergooding, @pgovind, @jeffhandley |
Added |
Thanks! Notably we don't expose unsigned |
Looks good as proposed namespace System
{
public static class Math
{
public static nint Abs(nint value);
public static nuint Clamp(nuint value, nuint min, nuint max);
public static nint Clamp(nint value, nint min, nint max);
public static nint DivRem(nint a, nint b, out nint result);
public static nint Max(nint val1, nint val2);
public static nuint Max(nuint val1, nuint val2);
public static nint Min(nint val1, nint val2);
public static nuint Min(nuint val1, nuint val2);
public static nint Sign(nint value);
}
} |
See the decision on #42156 for |
Can we also add Math.Pow() to the list ? Presently it operates only on doubles. |
@Praveen-Rai I think that should be a separate proposal, considering the issues that were previously raised about it at #25784. |
Background and Motivation
C# 9 includes the new
nint/nuint
types, but it gets pretty awkward to use them in code that was previously usingMath
APIs such asMin
orMax
. This proposal is about adding overloads for theint/uint
APIs inSystem.Math
to supportnint/nuint
.Right now you either have to manually write ternary operators everywhere to work around this, or just stick with
int/uint
.Proposed API
The text was updated successfully, but these errors were encountered: