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

This operator-division operator of double division operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe number by which this number will be divided


✐ Examples

1 Divide two numbers (10.0 / 2.0)

In this example,

  1. We use the `/` operator to divide 10.0 by 2.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 / 2.0;
  print('Result: $result');
}

Output

Result: 5.0

2 Divide two variables (a / b)

In this example,

  1. We define two variables a and b with values 15.0 and 3.0 respectively.
  2. We then use the `/` operator to divide a by b.
  3. The result is stored in the variable result.
  4. 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,

  1. We use the `/` operator to divide -20.0 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 = -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.