operator unary- abstract method Null safety

num operator unary-()

The negation of this value.

The negation of a number is a number of the same kind (int or double) representing the negation of the numbers numerical value (the result of subtracting the number from zero), if that value exists.

Negating a double gives a number with the same magnitude as the original value (number.abs() == (-number).abs()), and the opposite sign (-(number.sign) == (-number).sign).

Negating an integer, -number, is equivalent to subtracting it from zero, 0 - number.

(Both properties generally also hold for the other type, but with a few edge case exceptions).

Implementation

num operator -();