Dart格式化输出

类似于保留几位小数,直接 n.toStringAsFixed()

例如:

1.toStringAsFixed(3);  // 1.000
(4321.12345678).toStringAsFixed(5);  // 4321.12346
1000000000000000000000.toStringAsFixed(3); // 1e+21
5.25.toStringAsFixed(0); // 5

16进制输出

12.toRadixString(16);  // c
原文地址:https://www.cnblogs.com/ciml/p/10071660.html