Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/NormandoRamirezDelgado/6C-Febrero-2026/llms.txt

Use this file to discover all available pages before exploring further.

Overview

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

Arithmetic Operators Table

OperatorDescriptionExampleResult
+Addition10 + 313
-Subtraction10 - 37
*Multiplication10 * 330
/Division (returns double)10 / 33.333...
~/Integer Division10 ~/ 33
%Modulo (remainder)10 % 31
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:
void main() {
  //Operadores Aritméticos
  int numeroUno = 10;
  int numeroDos = 3;

  print(numeroUno + numeroDos);    // Suma: 13
  print(numeroUno - numeroDos);    // Resta: 7
  print(numeroUno * numeroDos);    // Multiplicación: 30
  print(numeroUno / numeroDos);    // División: 3.333...
  print(numeroUno ~/ numeroDos);   // División entera: 3
  print(numeroUno % numeroDos);    // Módulo: 1
}

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
int a = 10;
int b = 3;

print(a / b);   // Output: 3.3333333333333335 (double)
print(a ~/ b);  // Output: 3 (int)
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

int total = 10;
int divisor = 3;
int remainder = total % divisor;  // remainder = 1

Integer Division for Grouping

int students = 25;
int groupSize = 4;
int numberOfGroups = students ~/ groupSize;  // 6 complete groups
int studentsLeft = students % groupSize;     // 1 student left over

Build docs developers (and LLMs) love