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) → double

This operator-modulo operator of double euclidean modulo operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe divisor


✐ Examples

1 Calculate the remainder of division (10.0 % 3.0)

In this example,

  1. We use the `%` operator to compute the remainder of dividing 10.0 by 3.0.
  2. The result is stored in the variable result.
  3. 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,

  1. We use the `%` operator to compute the remainder of dividing 15.5 by 4.0.
  2. The result is stored in the variable result.
  3. 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,

  1. We use the `%` operator to compute the remainder of dividing 20.0 by 7.5.
  2. The result is stored in the variable result.
  3. 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.