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) → boolThis operator-less-than-or-equal-to operator of double relational less than or equal operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the number to compare against |
✐ Examples
1 Check if a number is less than or equal to another number (a <= b)
In this example,
- We define two variables
aandbwith values5.0and10.0respectively. - We use the `<=` operator to compare
awithb. - The result is stored in the variable
result. - 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,
- We define two variables
xandywith the same value7.0. - We use the `<=` operator to compare
xwithy. - The result is stored in the variable
result. - 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,
- We define two variables
pandqwith values20.0and10.0respectively. - We use the `<=` operator to compare
pwithq. - The result is stored in the variable
result. - 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.