BigInteger.Subtract(BigInteger, BigInteger) 方法

定義

某個 BigInteger 值減去另一個值,並且傳回結果。

public:
 static System::Numerics::BigInteger Subtract(System::Numerics::BigInteger left, System::Numerics::BigInteger right);
public static System.Numerics.BigInteger Subtract (System.Numerics.BigInteger left, System.Numerics.BigInteger right);
static member Subtract : System.Numerics.BigInteger * System.Numerics.BigInteger -> System.Numerics.BigInteger
Public Shared Function Subtract (left As BigInteger, right As BigInteger) As BigInteger

參數

left
BigInteger

要被減的值 (被減數)。

right
BigInteger

要減去的值 (減數)。

傳回

right 減去 left 的結果。

備註

不支援自定義運算子的語言可以使用 Subtract 方法來使用 BigInteger 值來執行減法。

方法 Subtract 在具現化 BigInteger 變數時,藉由指派減法所產生的差異來具現化變數時,此方法是一個有用的替代方法,如下列範例所示。

// The statement
//    BigInteger number = Int64.MinValue - Int64.MaxValue;
// produces compiler error CS0220: The operation overflows at compile time in checked mode.
// The alternative:
BigInteger number = BigInteger.Subtract(Int64.MinValue, Int64.MaxValue);
' The statement
'    Dim number As BigInteger = Int64.MinValue - Int64.MaxValue
' produces compiler error BC30439: Constant expression not representable in type 'Long'.
' The alternative:
Dim number As BigInteger = BigInteger.Subtract(Int64.MinValue, Int64.MaxValue)

適用於

另請參閱