Dart double operator-less-than
Syntax & Examples
double.operator-less-than operator
The relational less than operator compares the given numeric value with another numeric value and returns true if the first value is less than the second value; otherwise, it returns false.
Syntax of double.operator-less-than
The syntax of double.operator-less-than operator is:
operator <(num other) → boolThis operator-less-than operator of double relational less than operator.
Parameters
| Parameter | Optional/Required | Description |
|---|---|---|
other | required | the numeric value to compare with |
✐ Examples
1 Example with positive values
In this example,
- We create two positive numeric values
numValue1andnumValue2with values 10 and 5 respectively. - We then use the less than operator
<to comparenumValue1withnumValue2. - We print the comparison result to standard output.
Dart Program
void main() {
num numValue1 = 10;
num numValue2 = 5;
bool isLessThan = numValue1 < numValue2;
print('Is $numValue1 less than $numValue2: $isLessThan');
}Output
Is 10 less than 5: false
2 Example with mixed positive and negative values
In this example,
- We create two numeric values
numValue1andnumValue2with values 3.5 and 6 respectively. - We then use the less than operator
<to comparenumValue1withnumValue2. - We print the comparison result to standard output.
Dart Program
void main() {
num numValue1 = 3.5;
num numValue2 = 6;
bool isLessThan = numValue1 < numValue2;
print('Is $numValue1 less than $numValue2: $isLessThan');
}Output
Is 3.5 less than 6: true
3 Example with negative values
In this example,
- We create two negative numeric values
numValue1andnumValue2with values -8 and -3 respectively. - We then use the less than operator
<to comparenumValue1withnumValue2. - We print the comparison result to standard output.
Dart Program
void main() {
num numValue1 = -8;
num numValue2 = -3;
bool isLessThan = numValue1 < numValue2;
print('Is $numValue1 less than $numValue2: $isLessThan');
}Output
Is -8 less than -3: true
Summary
In this Dart tutorial, we learned about operator-less-than operator of double: the syntax and few working examples with output and detailed explanation for each example.