BigInteger.UnaryNegation(BigInteger) BigInteger.UnaryNegation(BigInteger) BigInteger.UnaryNegation(BigInteger) BigInteger.UnaryNegation(BigInteger) Operator


Negates a specified BigInteger value.

 static System::Numerics::BigInteger operator -(System::Numerics::BigInteger value);
public static System.Numerics.BigInteger operator - (System.Numerics.BigInteger value);
static member ( ~- ) : System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Operator - (value As BigInteger) As BigInteger


BigInteger BigInteger BigInteger BigInteger

The value to negate.


The result of the value parameter multiplied by negative one (-1).


The following example illustrates three different ways to negate the value of a BigInteger object.

BigInteger number = 12645002;

Console.WriteLine(BigInteger.Negate(number));        // Displays -12645002
Console.WriteLine(-number);                          // Displays -12645002
Console.WriteLine(number * BigInteger.MinusOne);     // Displays -12645002
Dim number As BigInteger = 12645002

Console.WriteLine(BigInteger.Negate(number))          ' Displays -12645002
Console.WriteLine(-number)                            ' Displays -12645002
Console.WriteLine(number * BigInteger.MinusOne)       ' Displays -12645002


The UnaryNegation method defines the operation of the unary negation operator (or the additive inverse operator) for BigInteger values. The operation produces a value that results in 0 (zero) when it is added to the original number. Languages that do not support custom operators can call the Negate method instead.

The equivalent method for this operator is BigInteger.Negate(BigInteger)

Applies to