Hi so i have a double seems like this
d1 = 12.106
and i need to show in to a string '12.130'
double num1 = double. parse((12.3404). toStringAsFixed(3));
well i expected to return "12.130" but it returned "12.13"
the thing i need a string "12.130" instead "12.13"
double num1 = double. parse((12.3404). toStringAsFixed(4));
so tried this one again but also failed
well then number must be shown 3 decimals even if the last is 0
where or what should i have to fix?
CodePudding user response:
I understand you have the following variable:
double d = 12.130;
and now you want to convert it to a string with the following value: String s = "12.130"
This should work:
String res = d.toStringAsFixed(3) //"12.130"