当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。