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

 

posted @ 2018-12-05 16:22  Coding&Life  阅读(9129)  评论(0编辑  收藏  举报