Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!

We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!

Learn from Guru Rajesh Kumar and double your salary in just one year.



Get Started Now!

Dart/Flutter – How to convert one dataType to other Data

Uncategorized

Int to dubble

To convert a int to double in Dart, we can use one of the built-in methods depending on your need:

void main() {
  int i = 5;
  print(i.toDouble());          // 5.0
}

toInt( ) or truncate( ):

void main() {
  dubble i = 5.0;
  print(i.toInt());           // 5
 
}

round( ):

return the closest/nearest integer.

void main() {
int i = 4.7;
print(i.round()); // 5.0
}

ceil( ):

return the least integer that is not smaller than this number.

void main() {
  int i = 5.3;
  print(i.ceil());          // 5.0
}

floor( ):

return the greatest integer not greater than this number

void main() {
  int i = 5.3;
   print(i.floor());          // 5
 
}
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x