Skip to content

Commit 3d848a0

Browse files
fix: Add nint and nuint as operators for binary operations (#44973)
Reading the design, it mentions that it seems to be supported (https://learn.microsoft.com/dotnet/csharp/language-reference/proposals/csharp-9.0/native-integers?WT.mc_id=8B97120A00B57354#constants) and when looking at the bcl they seem to support `IBinaryInteger`, `IBinaryNumber` and `IBitwiseOperators`. https://source.dot.net/#System.Private.CoreLib/src/libraries/System.Private.CoreLib/src/System/UIntPtr.cs,33
1 parent c9e98ab commit 3d848a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/csharp/language-reference/operators/bitwise-and-shift-operators.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ The bitwise and shift operators include unary bitwise complement, binary left an
4444
- Binary [`<<` (left shift)](#left-shift-operator-), [`>>` (right shift)](#right-shift-operator-), and [`>>>` (unsigned right shift)](#unsigned-right-shift-operator-) operators
4545
- Binary [`&` (logical AND)](#logical-and-operator-), [`|` (logical OR)](#logical-or-operator-), and [`^` (logical exclusive OR)](#logical-exclusive-or-operator-) operators
4646

47-
Those operators are defined for the `int`, `uint`, `long`, and `ulong` types. When both operands are of other integral types (`sbyte`, `byte`, `short`, `ushort`, or `char`), their values are converted to the `int` type, which is also the result type of an operation. When operands are of different integral types, their values are converted to the closest containing integral type. For more information, see the [Numeric promotions](~/_csharpstandard/standard/expressions.md#1247-numeric-promotions) section of the [C# language specification](~/_csharpstandard/standard/README.md). The compound operators (such as `>>=`) don't convert their arguments to `int` or have the result type as `int`.
47+
Those operators are defined for the `int`, `uint`, `long`, `ulong`, `nint`, and `nuint` types. When both operands are of other integral types (`sbyte`, `byte`, `short`, `ushort`, or `char`), their values are converted to the `int` type, which is also the result type of an operation. When operands are of different integral types, their values are converted to the closest containing integral type. For more information, see the [Numeric promotions](~/_csharpstandard/standard/expressions.md#1247-numeric-promotions) section of the [C# language specification](~/_csharpstandard/standard/README.md). The compound operators (such as `>>=`) don't convert their arguments to `int` or have the result type as `int`.
4848

4949
The `&`, `|`, and `^` operators are also defined for operands of the `bool` type. For more information, see [Boolean logical operators](boolean-logical-operators.md).
5050

0 commit comments

Comments
 (0)