How do you round a double in Dart to a given degree of precision AFTER the decimal point?

前端 未结 12 1077
[愿得一人]
[愿得一人] 2020-12-08 03:46

Given a double, I want to round it to a given number of points of precision after the decimal point, similar to PHP\'s round() function.

The closest thing I

12条回答
  •  忘掉有多难
    2020-12-08 03:59

    I used toStringAsFixed() method , to round number to specific numbers after the decimal point EX : double num = 22.48132906 and when I rounded to two numbers like this : print(num.toStringAsFixed(2) ;

    it printed 22.48

    and when I rounded to one number .. printed 22.5

提交回复
热议问题