dart:core
庫中BigInt.bitLength
屬性的用法介紹如下。
用法:
int bitLength
返回存儲此大整數所需的最小位數。
位數不包括符號位,它給出了非負(無符號)值的自然長度。對負值進行補碼以返回與符號位不同的第一位的位位置。
要找到將值存儲為有符號值所需的位數,請加一,即使用 x.bitLength + 1
。
x.bitLength == (-x-1).bitLength;
BigInt.from(3).bitLength == 2; // 00000011
BigInt.from(2).bitLength == 2; // 00000010
BigInt.from(1).bitLength == 1; // 00000001
BigInt.from(0).bitLength == 0; // 00000000
BigInt.from(-1).bitLength == 0; // 11111111
BigInt.from(-2).bitLength == 1; // 11111110
BigInt.from(-3).bitLength == 2; // 11111101
BigInt.from(-4).bitLength == 2; // 11111100
相關用法
- Dart BigInt.toRadixString用法及代碼示例
- Dart BigInt.operator_divide用法及代碼示例
- Dart BigInt.from用法及代碼示例
- Dart BigInt.isValidInt用法及代碼示例
- Dart BigInt.toDouble用法及代碼示例
- Dart BigInt.parse用法及代碼示例
- Dart BigInt.gcd用法及代碼示例
- Dart BigInt.operator_truncate_divide用法及代碼示例
- Dart BigInt.tryParse用法及代碼示例
- Dart BigInt.compareTo用法及代碼示例
- Dart BigInt.remainder用法及代碼示例
- Dart BigInt.toInt用法及代碼示例
- Dart BigInt.operator_modulo用法及代碼示例
- Dart BigInt.toUnsigned用法及代碼示例
- Dart BigInt.toString用法及代碼示例
- Dart BigInt.pow用法及代碼示例
- Dart BigInt.toSigned用法及代碼示例
- Dart BigInt用法及代碼示例
- Dart Base64Encoder用法及代碼示例
- Dart ByteData.view用法及代碼示例
- Dart ByteData用法及代碼示例
- Dart Base64Decoder用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart AttributeClassSet.intersection用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 bitLength property。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。