Dart double operator-division
Syntax & Examples
double.operator-division operator
The `/` operator is used for division, which divides one number by another.
Syntax of double.operator-division
The syntax of double.operator-division operator is:
operator /(num other) → doubleThis operator-division operator of double division operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the number by which this number will be divided |
✐ Examples
1 Divide two numbers (10.0 / 2.0)
In this example,
- We use the `/` operator to divide
10.0by2.0. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double result = 10.0 / 2.0;
print('Result: $result');
}Output
Result: 5.0
2 Divide two variables (a / b)
In this example,
- We define two variables
aandbwith values15.0and3.0respectively. - We then use the `/` operator to divide
abyb. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double a = 15.0;
double b = 3.0;
double result = a / b;
print('Result: $result');
}Output
Result: 5.0
3 Divide a negative number by a positive number (-20.0 / 4.0)
In this example,
- We use the `/` operator to divide
-20.0by4.0. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double result = -20.0 / 4.0;
print('Result: $result');
}Output
Result: -5.0
Summary
In this Dart tutorial, we learned about operator-division operator of double: the syntax and few working examples with output and detailed explanation for each example.