I couldn't find a way to round double to 2 decimal places and remove trailing zeros in Dart. I found a way to round but it doesn't work if I try to truncate trailing zero.
Here is what I am trying to do:
double x = 5.0; double y = 9.25843223423423; double z = 10.10; print(x); //Expected output --> 5 print(y); //Expected output --> 9.26 print(z); //Expected output --> 10.1
https://stackoverflow.com/questions/66961073/how-to-round-double-to-2-decimal-places-and-remove-zeros-if-exits-using-dart April 06, 2021 at 07:48AM
没有评论:
发表评论