integer arithmetic
Maths on whole numbers only, which is all bash can do itself: 7 / 2 gives 3, with the remainder dropped.
In more detail
Use $(( )) or let for integer maths and % for the remainder. For fractions, hand the calculation to bc or awk.
Related terms
- arithmetic expansion — Evaluating whole-number maths inside $(( )) and replacing it with the result; (( )) on its own evaluates without printing anything.
- bc — A calculator program with arbitrary precision that does the decimal maths bash itself cannot.
- floating-point number — A number with a fractional part stored in binary, which can only approximate most decimal values.
Taught in
- Arithmetic: Double Parentheses, let And bc — Bash Scripting & Command Line Automation
- Functions, local And declare — Bash Scripting & Command Line Automation