當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Dart BigInt.remainder用法及代碼示例

dart:core 庫中BigInt.remainder 方法的用法介紹如下。

用法:

BigInt remainder(
   BigInt other   
)

返回 this 除以 other 的餘數。

此操作的結果 r 滿足:this == (this ~/ other) * other + r 。因此,餘數 r 與除法器 this 具有相同的符號。

例子:

print(BigInt.from(5).remainder(BigInt.from(3))); // 2
print(BigInt.from(-5).remainder(BigInt.from(3))); // -2
print(BigInt.from(5).remainder(BigInt.from(-3))); // 2
print(BigInt.from(-5).remainder(BigInt.from(-3))); // -2

相關用法


注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 remainder method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。