0PricingLogin
Dart Academy · Lesson

int vs double and Integer Division

Mix number types and use the tilde-slash operator.

Two Number Types

Dart has two number types: int for whole numbers and double for decimals. Both descend from num, so they mix in math. 🔢

void main() {
  int age = 30;
  double price = 4.99;
}

int Holds Whole Numbers

An int stores values with no fractional part, like counts and indexes. Writing 5 with no dot makes it an int automatically.

void main() {
  int count = 5;
  print(count); // 5
}

All lessons in this course

  1. Arithmetic and Operator Precedence
  2. int vs double and Integer Division
  3. Parsing and Converting Numbers
  4. The dart:math Toolkit
← Back to Dart Academy