首页 > 技术文章 > Dart格式化输出

ciml 2018-12-05 16:22 原文

类似于保留几位小数,直接 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

 

推荐阅读