Dart double operator-greater-than
Syntax & Examples


double.operator-greater-than operator

The `>` operator is used to determine if a number is greater than another number.


Syntax of double.operator-greater-than

The syntax of double.operator-greater-than operator is:

operator >(num other) → bool

This operator-greater-than operator of double relational greater than operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe number to compare against


✐ Examples

1 Check if a number is greater than another number (a > b)

In this example,

  1. We define two variables a and b with values 5.0 and 10.0 respectively.
  2. We use the `>` operator to compare a with b.
  3. The result is stored in the variable result.
  4. We print the result to standard output.

Dart Program

void main() {
  double a = 5.0;
  double b = 10.0;
  bool result = a > b;
  print('Result: $result');
}

Output

Result: false

2 Check if a number is greater than another number (x > y)

In this example,

  1. We define two variables x and y with the same value 7.0.
  2. We use the `>` operator to compare x with y.
  3. The result is stored in the variable result.
  4. We print the result to standard output.

Dart Program

void main() {
  double x = 7.0;
  double y = 7.0;
  bool result = x > y;
  print('Result: $result');
}

Output

Result: false

3 Check if a number is greater than another number (p > q)

In this example,

  1. We define two variables p and q with values 20.0 and 10.0 respectively.
  2. We use the `>` operator to compare p with q.
  3. The result is stored in the variable result.
  4. We print the result to standard output.

Dart Program

void main() {
  double p = 20.0;
  double q = 10.0;
  bool result = p > q;
  print('Result: $result');
}

Output

Result: true

Summary

In this Dart tutorial, we learned about operator-greater-than operator of double: the syntax and few working examples with output and detailed explanation for each example.