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
+39-2Lines changed: 39 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -287,6 +287,8 @@ As an example of numeric promotion, consider the predefined implementations of t
287
287
```csharp
288
288
intoperator*(intx, inty);
289
289
uintoperator*(uintx, uinty);
290
+
nintoperator*(nintx, ninty);
291
+
nuintoperator*(nuintx, nuinty);
290
292
longoperator*(longx, longy);
291
293
ulongoperator*(ulongx, ulongy);
292
294
floatoperator*(floatx, floaty);
@@ -298,8 +300,6 @@ When overload resolution rules ([§12.6.4](expressions.md#1264-overload-resoluti
298
300
299
301
> *Example*: For the operation `b * s`, where `b` is a `byte` and `s` is a `short`, overload resolution selects `operator *(int, int)` as the best operator. Thus, the effect is that `b` and `s` are converted to `int`, and the type of the result is `int`. Likewise, for the operation `i * d`, where `i` is an `int` and `d` is a `double`, `overload` resolution selects `operator *(double, double)` as the best operator. *end example*
300
302
301
-
There are no predefined operators for dealing with native integer ([§8.3.6](types.md#836-integral-types)). Instead, `nint` and `nuint` values shall be promoted to `long` and `ulong`, respectively, and the resulting corresponding predefined operators used instead.
302
-
303
303
**End of informative text.**
304
304
305
305
#### 12.4.7.2 Unary numeric promotions
@@ -3733,6 +3733,8 @@ For an operation of the form `+x`, unary operator overload resolution ([§12.4.
3733
3733
```csharp
3734
3734
intoperator+(intx);
3735
3735
uintoperator+(uintx);
3736
+
nintoperator+(nintx);
3737
+
nuintoperator+(nuintx);
3736
3738
longoperator+(longx);
3737
3739
ulongoperator+(ulongx);
3738
3740
floatoperator+(floatx);
@@ -3752,6 +3754,7 @@ For an operation of the form `–x`, unary operator overload resolution ([§12.
3752
3754
3753
3755
```csharp
3754
3756
intoperator –(intx);
3757
+
nintoperator –(nintx);
3755
3758
longoperator –(longx);
3756
3759
```
3757
3760
@@ -3801,6 +3804,8 @@ For an operation of the form `~x`, unary operator overload resolution ([§12.4.4
3801
3804
```csharp
3802
3805
intoperator~(intx);
3803
3806
uintoperator~(uintx);
3807
+
nintoperator~(nintx);
3808
+
nuintoperator~(nuintx);
3804
3809
longoperator~(longx);
3805
3810
ulongoperator~(ulongx);
3806
3811
```
@@ -4146,6 +4151,8 @@ The predefined multiplication operators are listed below. The operators all comp
4146
4151
```csharp
4147
4152
intoperator*(intx, inty);
4148
4153
uintoperator*(uintx, uinty);
4154
+
nintoperator*(nintx, ninty);
4155
+
nuintoperator*(nuintx, nuinty);
4149
4156
longoperator*(longx, longy);
4150
4157
ulongoperator*(ulongx, ulongy);
4151
4158
```
@@ -4193,6 +4200,8 @@ The predefined division operators are listed below. The operators all compute th
4193
4200
```csharp
4194
4201
intoperator/(intx, inty);
4195
4202
uintoperator/(uintx, uinty);
4203
+
nintoperator/(nintx, ninty);
4204
+
nuintoperator/(nuintx, nuinty);
4196
4205
longoperator/(longx, longy);
4197
4206
ulongoperator/(ulongx, ulongy);
4198
4207
```
@@ -4244,6 +4253,8 @@ The predefined remainder operators are listed below. The operators all compute t
4244
4253
```csharp
4245
4254
intoperator%(intx, inty);
4246
4255
uintoperator%(uintx, uinty);
4256
+
nintoperator%(nintx, ninty);
4257
+
nuintoperator%(nuintx, nuinty);
4247
4258
longoperator%(longx, longy);
4248
4259
ulongoperator%(ulongx, ulongy);
4249
4260
```
@@ -4294,6 +4305,8 @@ The predefined addition operators are listed below. For numeric and enumeration
4294
4305
```csharp
4295
4306
intoperator+(intx, inty);
4296
4307
uintoperator+(uintx, uinty);
4308
+
nintoperator+(nintx, ninty);
4309
+
nuintoperator+(nuintx, nuinty);
4297
4310
longoperator+(longx, longy);
4298
4311
ulongoperator+(ulongx, ulongy);
4299
4312
```
@@ -4396,6 +4409,8 @@ The predefined subtraction operators are listed below. The operators all subtrac
4396
4409
```csharp
4397
4410
intoperator –(intx, inty);
4398
4411
uintoperator –(uintx, uinty);
4412
+
nintoperator –(nintx, ninty);
4413
+
nuintoperator –(nuintx, nuinty);
4399
4414
longoperator –(longx, longy);
4400
4415
ulongoperator –(ulongx, ulongy
4401
4416
```
@@ -4521,6 +4536,8 @@ The predefined shift operators are listed below.
4521
4536
```csharp
4522
4537
intoperator<<(intx, intcount);
4523
4538
uintoperator<<(uintx, intcount);
4539
+
nintoperator<<(nintx, intcount);
4540
+
nuintoperator<<(nuintx, intcount);
4524
4541
longoperator<<(longx, intcount);
4525
4542
ulongoperator<<(ulongx, intcount);
4526
4543
```
@@ -4533,6 +4550,8 @@ The predefined shift operators are listed below.
4533
4550
```csharp
4534
4551
intoperator>>(intx, intcount);
4535
4552
uintoperator>>(uintx, intcount);
4553
+
nintoperator>>(nintx, intcount);
4554
+
nuintoperator>>(nuintx, intcount);
4536
4555
longoperator>>(longx, intcount);
4537
4556
ulongoperator>>(ulongx, intcount);
4538
4557
```
@@ -4619,31 +4638,43 @@ The predefined integer comparison operators are:
4619
4638
```csharp
4620
4639
booloperator==(intx, inty);
4621
4640
booloperator==(uintx, uinty);
4641
+
booloperator==(nintx, ninty);
4642
+
booloperator==(nuintx, nuinty);
4622
4643
booloperator==(longx, longy);
4623
4644
booloperator==(ulongx, ulongy);
4624
4645
4625
4646
booloperator!=(intx, inty);
4626
4647
booloperator!=(uintx, uinty);
4648
+
booloperator!=(nintx, ninty);
4649
+
booloperator!=(nuintx, nuinty);
4627
4650
booloperator!=(longx, longy);
4628
4651
booloperator!=(ulongx, ulongy);
4629
4652
4630
4653
booloperator<(intx, inty);
4631
4654
booloperator<(uintx, uinty);
4655
+
booloperator<(nintx, ninty);
4656
+
booloperator<(nuintx, nuinty);
4632
4657
booloperator<(longx, longy);
4633
4658
booloperator<(ulongx, ulongy);
4634
4659
4635
4660
booloperator>(intx, inty);
4636
4661
booloperator>(uintx, uinty);
4662
+
booloperator>(nintx, ninty);
4663
+
booloperator>(nuintx, nuinty);
4637
4664
booloperator>(longx, longy);
4638
4665
booloperator>(ulongx, ulongy);
4639
4666
4640
4667
booloperator<=(intx, inty);
4641
4668
booloperator<=(uintx, uinty);
4669
+
booloperator<=(nintx, ninty);
4670
+
booloperator<=(nuintx, nuinty);
4642
4671
booloperator<=(longx, longy);
4643
4672
booloperator<=(ulongx, ulongy);
4644
4673
4645
4674
booloperator>=(intx, inty);
4646
4675
booloperator>=(uintx, uinty);
4676
+
booloperator>=(nintx, ninty);
4677
+
booloperator>=(nuintx, nuinty);
4647
4678
booloperator>=(longx, longy);
4648
4679
booloperator>=(ulongx, ulongy);
4649
4680
```
@@ -5098,16 +5129,22 @@ The predefined integer logical operators are:
0 commit comments