Dart double operator-modulo
Syntax & Examples
double.operator-modulo operator
The `%` operator computes the remainder of the division of one number by another.
Syntax of double.operator-modulo
The syntax of double.operator-modulo operator is:
operator %(num other) → doubleThis operator-modulo operator of double euclidean modulo operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the divisor |
✐ Examples
1 Calculate the remainder of division (10.0 % 3.0)
In this example,
- We use the `%` operator to compute the remainder of dividing
10.0by3.0. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double result = 10.0 % 3.0;
print('Result: $result');
}Output
Result: 1.0
2 Calculate the remainder of division (15.5 % 4.0)
In this example,
- We use the `%` operator to compute the remainder of dividing
15.5by4.0. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double result = 15.5 % 4.0;
print('Result: $result');
}Output
Result: 3.5
3 Calculate the remainder of division (20.0 % 7.5)
In this example,
- We use the `%` operator to compute the remainder of dividing
20.0by7.5. - The result is stored in the variable
result. - We print the result to standard output.
Dart Program
void main() {
double result = 20.0 % 7.5;
print('Result: $result');
}Output
Result: 5.0
Summary
In this Dart tutorial, we learned about operator-modulo operator of double: the syntax and few working examples with output and detailed explanation for each example.