Skip to main content

Overview

Arithmetic operators allow you to perform mathematical calculations in Dart. These operators work with numeric types like int and double.

Arithmetic Operators Table

The ~/ operator performs integer division and returns only the whole number part, discarding any remainder.

Basic Example

Here’s a complete example demonstrating all arithmetic operators:

Key Differences

Division (/) vs Integer Division (~/)

The key difference between these two operators:
  • Division (/): Returns a double with the exact result including decimals
  • Integer Division (~/): Returns an int with only the whole number part
Use the modulo operator % to get the remainder of a division. This is particularly useful for checking if a number is even or odd: number % 2 == 0 means the number is even.

Practical Uses

Calculating Remainder

Integer Division for Grouping