dart:core
库中BigInt.toRadixString
方法的用法介绍如下。
用法:
String toRadixString(
int radix
)
将 this 转换为给定 radix
中的字符串表示形式。
在字符串表示中,'9' 以上的数字使用小写字母,'a' 为 10,'z' 为 35。
radix
参数必须是 2 到 36 范围内的整数。
例子:
// Binary (base 2).
print(BigInt.from(12).toRadixString(2)); // 1100
print(BigInt.from(31).toRadixString(2)); // 11111
print(BigInt.from(2021).toRadixString(2)); // 11111100101
print(BigInt.from(-12).toRadixString(2)); // -1100
// Octal (base 8).
print(BigInt.from(12).toRadixString(8)); // 14
print(BigInt.from(31).toRadixString(8)); // 37
print(BigInt.from(2021).toRadixString(8)); // 3745
// Hexadecimal (base 16).
print(BigInt.from(12).toRadixString(16)); // c
print(BigInt.from(31).toRadixString(16)); // 1f
print(BigInt.from(2021).toRadixString(16)); // 7e5
// Base 36.
print(BigInt.from(35 * 36 + 1).toRadixString(36)); // z1
相关用法
- Dart BigInt.toDouble用法及代码示例
- Dart BigInt.toInt用法及代码示例
- Dart BigInt.toUnsigned用法及代码示例
- Dart BigInt.toString用法及代码示例
- Dart BigInt.toSigned用法及代码示例
- Dart BigInt.tryParse用法及代码示例
- Dart BigInt.operator_divide用法及代码示例
- Dart BigInt.from用法及代码示例
- Dart BigInt.isValidInt用法及代码示例
- Dart BigInt.parse用法及代码示例
- Dart BigInt.bitLength用法及代码示例
- Dart BigInt.gcd用法及代码示例
- Dart BigInt.operator_truncate_divide用法及代码示例
- Dart BigInt.compareTo用法及代码示例
- Dart BigInt.remainder用法及代码示例
- Dart BigInt.operator_modulo用法及代码示例
- Dart BigInt.pow用法及代码示例
- Dart BigInt用法及代码示例
- Dart Base64Encoder用法及代码示例
- Dart ByteData.view用法及代码示例
- Dart ByteData用法及代码示例
- Dart Base64Decoder用法及代码示例
- Dart MapMixin.containsKey用法及代码示例
- Dart Iterator用法及代码示例
- Dart AttributeClassSet.intersection用法及代码示例
注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 toRadixString method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。