Answers for "change double to int and include decimals dart"

3

double variable into 2 decimal places flutter

double num1 = double.parse((12.3412).toStringAsFixed(2));
// 12.34

double num2 = double.parse((12.5668).toStringAsFixed(2));
// 12.57

double num3 = double.parse((-12.3412).toStringAsFixed(2));
// -12.34

double num4 = double.parse((-12.3456).toStringAsFixed(2));
// -12.35
Posted by: Guest on November-29-2020
-1

double to int in dart

int calc_ranks(ranks) {
    double multiplier = .5;
    return (multiplier * ranks).round();
}
Posted by: Guest on November-23-2020

Browse Popular Code Answers by Language