Reputation:
I want to assign two variables to integer and decimal parts on double.
how to do it?
Upvotes: 1
Views: 4626
Reputation: 4144
final abc = 1.4;
final numberValue = abc.floor();
final floatValue = abc - numberValue;
print(abc);
print(numberValue);
print(floatValue);
Upvotes: 1
Reputation: 41
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
Upvotes: 4
Reputation: 658263
One way would be
int x = abc.toInt()
int y = int.tryParse(abc.toString().split('.')[1]);
Upvotes: 5