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


Dart BigInt.compareTo用法及代碼示例

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

用法:

int compareTo(
   BigInt other   
)
      override

將此與 other 進行比較。

如果 this 小於 other 則返回負數,如果它們相等則返回零,如果 this 大於 other 則返回正數。

例子:

print(BigInt.from(1).compareTo(BigInt.from(2))); // => -1
print(BigInt.from(2).compareTo(BigInt.from(1))); // => 1
print(BigInt.from(1).compareTo(BigInt.from(1))); // => 0

相關用法


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