Dart double operator-less-than-or-equal-to
Syntax & Examples


double.operator-less-than-or-equal-to operator

The `<=` operator is used to determine if a number is less than or equal to another number.


Syntax of double.operator-less-than-or-equal-to

The syntax of double.operator-less-than-or-equal-to operator is:

operator <=(num other) → bool

This operator-less-than-or-equal-to operator of double relational less than or equal operator.

Parameters

ParameterOptional/RequiredDescription
otherrequiredthe number to compare against


✐ Examples

1 Check if a number is less than or equal to 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: true

2 Check if two numbers are equal (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: true

3 Check if a number is less than or equal to 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: false

Summary

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