Overview
Arithmetic operators allow you to perform mathematical calculations in Dart. These operators work with numeric types likeint 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 adoublewith the exact result including decimals - Integer Division (
~/): Returns anintwith only the whole number part