dart:core
庫中num.toStringAsFixed
方法的用法介紹如下。
用法:
String toStringAsFixed(
int fractionDigits
)
此數字的小數點string-representation。
在計算字符串表示之前將此數字轉換為 double,如 toDouble 。
如果 this
的絕對值大於或等於 10^21
,則此方法返回由 this.toStringAsExponential()
計算的 index 表示。否則,結果是最接近的字符串表示,小數點後正好有fractionDigits
數字。如果fractionDigits
等於0,則省略小數點。
參數 fractionDigits
必須是滿足: 0 <= fractionDigits <= 20
的整數。
例子:
1.toStringAsFixed(3); // 1.000
(4321.12345678).toStringAsFixed(3); // 4321.123
(4321.12345678).toStringAsFixed(5); // 4321.12346
123456789012345.toStringAsFixed(3); // 123456789012345.000
10000000000000000.toStringAsFixed(4); // 10000000000000000.0000
5.25.toStringAsFixed(0); // 5
相關用法
- Dart num.toStringAsExponential用法及代碼示例
- Dart num.toStringAsPrecision用法及代碼示例
- Dart num.toString用法及代碼示例
- Dart num.tryParse用法及代碼示例
- Dart num.sign用法及代碼示例
- Dart num.abs用法及代碼示例
- Dart num.remainder用法及代碼示例
- Dart num.compareTo用法及代碼示例
- Dart num.operator_modulo用法及代碼示例
- Dart num.parse用法及代碼示例
- Dart num.clamp用法及代碼示例
- Dart MapMixin.containsKey用法及代碼示例
- Dart Iterator用法及代碼示例
- Dart AttributeClassSet.intersection用法及代碼示例
- Dart TransformList.last用法及代碼示例
- Dart FileList.first用法及代碼示例
- Dart CanvasRenderingContext2D.drawImageScaledFromSource用法及代碼示例
- Dart FileList.length用法及代碼示例
- Dart Iterable.takeWhile用法及代碼示例
- Dart LinkedHashMap用法及代碼示例
- Dart RegExp.pattern用法及代碼示例
- Dart StreamTransformer構造函數用法及代碼示例
- Dart JsArray.removeAt用法及代碼示例
- Dart ListMixin.expand用法及代碼示例
- Dart UriData.parse用法及代碼示例
注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 toStringAsFixed method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。