Numbers

There are two number classes in Dart: Integers and doubles.

Int

int is the class name for Integer.

int age = 35;

Doubles

Doubles are used for precision.

double pi = 3.14;

Dart automatically converts ints to doubles when necessary:

void main() {
  int x = 3; 
  double y = 4.4;
  print(x * y);
  // =>  13.200000000000001
}
void main() {
  int x = 3;
  int y = 2;
  print(x / y);
  // => 1.5
}

Sometimes, you might want integer math:

print(15 ~/ 2);
// => 7

The num class (super of both int and double), has a lot of familiar methods: ceil, floor, abs.