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) → boolThis operator-greater-than operator of double relational greater than operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the number to compare against |
✐ Examples
1 Check if a number is greater than 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: false
2 Check if a number is greater than another number (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: false
3 Check if a number is greater than 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: 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.