1

I want to assign two variables to integer and decimal parts on double. how to do it? enter image description here

3 Answers3

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
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