-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Closed
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numerics
Milestone
Description
Background and Motivation
C# 9 includes the new nint/nuint types, but it gets pretty awkward to use them in code that was previously using Math APIs such as Min or Max. This proposal is about adding overloads for the int/uint APIs in System.Math to support nint/nuint.
Right now you either have to manually write ternary operators everywhere to work around this, or just stick with int/uint.
Proposed API
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);
}
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api-approvedAPI was approved in API review, it can be implementedAPI was approved in API review, it can be implementedarea-System.Numerics