I want to assign two variables to integer and decimal parts on double.
how to do it?
Asked
Active
Viewed 4,134 times
3 Answers
5
One way would be
int x = abc.toInt()
int y = int.tryParse(abc.toString().split('.')[1]);

Günter Zöchbauer
- 623,577
- 216
- 2,003
- 1,567
4
final double abc = 1.4;
int a = int.parse(abc.toString().split(".")[0]);
int b = int.parse(abc.toString().split(".")[1]);
Try this out, it should work fine

David Buck
- 3,752
- 35
- 31
- 35

Mahadi Hassan Munna
- 41
- 2
0
final abc = 1.4;
final numberValue = abc.floor();
final floatValue = abc - numberValue;
print(abc);
print(numberValue);
print(floatValue);

MSARKrish
- 3,355
- 4
- 30
- 43