Επεξεργασία

Κοινή χρήση μέσω


BigInteger.UnaryNegation(BigInteger) Operator

Definition

Negates a specified BigInteger value.

public:
 static System::Numerics::BigInteger operator -(System::Numerics::BigInteger value);
public:
 static System::Numerics::BigInteger operator -(System::Numerics::BigInteger value) = System::Numerics::IUnaryNegationOperators<System::Numerics::BigInteger, System::Numerics::BigInteger>::op_UnaryNegation;
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

Parameters

value
BigInteger

The value to negate.

Returns

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

Implements

Examples

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
let number = 12645002I

printfn $"{BigInteger.Negate number}" // Displays -12645002
printfn $"{-number}" // Displays -12645002
printfn $"{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

Remarks

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