You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: standard/expressions.md
+18-3Lines changed: 18 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3612,11 +3612,12 @@ For an operation of the form `-x`, unary operator overload resolution ([§12.4.
3612
3612
3613
3613
```csharp
3614
3614
intoperator –(intx);
3615
+
nintoperator –(nintx);
3615
3616
longoperator –(longx);
3616
3617
```
3617
3618
3618
-
The result is computed by subtracting `X` from zero. If the value of `X` is the smallest representable value of the operand type (−2³¹ for `int` or −2⁶³ for `long`), then the mathematical negation of `X` is not representable within the operand type. If this occurs within a `checked` context, a `System.OverflowException` is thrown; if it occurs within an `unchecked` context, the result is the value of the operand and the overflow is not reported.
3619
-
3619
+
The result is computed by subtracting `X` from zero. If the value of `X` is the smallest representable value of the operand type (−2³¹ for `int`, the corresponding value for `nint`, or −2⁶³ for `long`), then the mathematical negation of `X` is not representable within the operand type. If this occurs within a `checked` context, a `System.OverflowException` is thrown; if it occurs within an `unchecked` context, the result is the value of the operand and the overflow is not reported.
3620
+
3620
3621
If the operand of the negation operator is of type `uint`, it is converted to type `long`, and the type of the result is `long`. An exception is the rule that permits the `int` value `−2147483648` (−2³¹) to be written as a decimal integer literal ([§6.4.5.3](lexical-structure.md#6453-integer-literals)).
3621
3622
3622
3623
If the operand of the negation operator is of type `nuint`, a compile-time error occurs.
@@ -3971,6 +3972,8 @@ The predefined multiplication operators are listed below. The operators all comp
3971
3972
```csharp
3972
3973
intoperator*(intx, inty);
3973
3974
uintoperator*(uintx, uinty);
3975
+
nintoperator*(nintx, ninty);
3976
+
nuintoperator*(nuintx, nuinty);
3974
3977
longoperator*(longx, longy);
3975
3978
ulongoperator*(ulongx, ulongy);
3976
3979
```
@@ -4018,6 +4021,8 @@ The predefined division operators are listed below. The operators all compute th
4018
4021
```csharp
4019
4022
intoperator/(intx, inty);
4020
4023
uintoperator/(uintx, uinty);
4024
+
nintoperator/(nintx, ninty);
4025
+
nuintoperator/(nuintx, nuinty);
4021
4026
longoperator/(longx, longy);
4022
4027
ulongoperator/(ulongx, ulongy);
4023
4028
```
@@ -4069,6 +4074,8 @@ The predefined remainder operators are listed below. The operators all compute t
4069
4074
```csharp
4070
4075
intoperator%(intx, inty);
4071
4076
uintoperator%(uintx, uinty);
4077
+
nintoperator%(nintx, ninty);
4078
+
nuintoperator%(nuintx, nuinty);
4072
4079
longoperator%(longx, longy);
4073
4080
ulongoperator%(ulongx, ulongy);
4074
4081
```
@@ -4119,6 +4126,8 @@ The predefined addition operators are listed below. For numeric and enumeration
4119
4126
```csharp
4120
4127
intoperator+(intx, inty);
4121
4128
uintoperator+(uintx, uinty);
4129
+
nintoperator+(nintx, ninty);
4130
+
nuintoperator+(nuintx, nuinty);
4122
4131
longoperator+(longx, longy);
4123
4132
ulongoperator+(ulongx, ulongy);
4124
4133
```
@@ -4221,8 +4230,10 @@ The predefined subtraction operators are listed below. The operators all subtrac
4221
4230
```csharp
4222
4231
intoperator –(intx, inty);
4223
4232
uintoperator –(uintx, uinty);
4233
+
nintoperator –(nintx, ninty);
4234
+
nuintoperator –(nuintx, nuinty);
4224
4235
longoperator –(longx, longy);
4225
-
ulongoperator –(ulongx, ulongy
4236
+
ulongoperator –(ulongx, ulongy);
4226
4237
```
4227
4238
4228
4239
In a `checked` context, if the difference is outside the range of the result type, a `System.OverflowException` is thrown. In an `unchecked` context, overflows are not reported and any significant high-order bits outside the range of the result type are discarded.
@@ -4346,6 +4357,8 @@ The predefined shift operators are listed below.
4346
4357
```csharp
4347
4358
intoperator<<(intx, intcount);
4348
4359
uintoperator<<(uintx, intcount);
4360
+
nintoperator<<(nintx, intcount);
4361
+
nuintoperator<<(nuintx, intcount);
4349
4362
longoperator<<(longx, intcount);
4350
4363
ulongoperator<<(ulongx, intcount);
4351
4364
```
@@ -4358,6 +4371,8 @@ The predefined shift operators are listed below.
0 commit comments