Order of floating point numbers
Syntax
$e1.isFloatGreater(e2, $precision)
Description
Determines whether the floating point number e1
is greater than the floating point number e2
, when rounding to precision
digits.
The expression is equivalent to
$e1.round($precision) > $e2.round($precision)
Parameter
Name | Type | Description | Mandatory | Default |
---|---|---|---|---|
e1 | Number | A floating point number to be compared with e2 . |
yes | |
e2 | Number | A floating point number to be compared to e1 . |
yes | |
precision | Number | A number that specifies how many decimal places to include. | yes |
Return value
Type: Boolean
true
, if e1
is greater than e2
.
Examples
Comparison with 4 decimal places
3.1314.isFloatGreater(3.1311, 4)
Output: true
Comparison with 2 decimal places
3.1314.isFloatGreater(3.1351, 2)
Output: false
By the given precision
= 2
the numbers 3.14 and 3.14 are compared to each other, which are the same.