7.6.2 Unary Minus Operator
For an operation of the form -x
, unary operator overload resolution (§7.2.3) is applied to select a specific operator implementation. The operand is converted to the parameter type of the selected operator, and the type of the result is the return type of the operator. The predefined negation operators are given here:
• Integer negation:
int operator -(int x); long operator -(long x);
The result is computed by subtracting x
from zero. If the value of x
is the smallest representable value of the operand type (−231 for int
or −263 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 ...
Get The C# Programming Language, Third Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.