Dart supports different arithmetic operators that can be used to performs mathematical calculations on the values and variables.
The basic arithmetic operations like addition, subtraction, multiplication, division, etc. are performed with these operators.
Arithmetic operations are performed according to the order or precedence of operators.
The general structure of every expression
Every expression will follow this general structure
Operand Operator Operand [Operator Operand] โฆ
- Operand represents data.
- An operator is a symbol used to perform operation such as mathematical, logical or relational producing a final result.
- For example,
x + ywherexandyare operands and+is an operator. - For example,
a = 7where,=is an operator andaand7are operands.
In this article, you will find Arithmetic operators provided by Dart.
Arithmetic operators
Basic mathematical calculations are preformed on numeric values with the use of arithmetic operators.
| Operator | Description | Example |
|---|---|---|
+ | Addition | x + y |
- | Subtraction | x - y |
-expr | Unary minus, aka negation (reverse the sign of the expression) | -x |
* | Multiplication | x * y |
/ | Division | x / y |
~/ | Divide, returning an integer result | x ~/ y |
% | Get the remainder of an integer division (modulo) | x % y |
- All of these listed operators are binary operators.
- All these operators also follow the general structure of
OperandOperatorOperand, meaning that an operator is always surrounded by two operands. - For example, an expression
x + yis a binary operation, where x and y are the two operands and + is an operator.
Hope you like this!
Keep helping and happy ๐ coding
Related Articles
Deepen your understanding with these curated continuations.
Dart - Comments
Improve your code readability with this guide to Dart comments. Learn single-line, multi-line, and doc comments for better Flutter development maintenance.
Dart - Semicolons
Learn why semicolons are mandatory in Dart and how to use them to terminate statements. Essential guide for developers moving to Flutter from other languages.
Dart - Relational Operators
Master relational operators in Dart and Flutter. Learn how to compare values using less than, greater than, and equal to operators in your mobile apps.