float_compare
Concepts
Section titled “Concepts”Behaviour
Section titled “Behaviour”- Evaluate a comparison of two XFL floating point numbers
- Return the result of the comparison as a boolean encoded in an int64_t.
- Evaluate a comparison of two XFL floating point numbers
- Returns an error code or the comparison result as a number.
Definition
Section titled “Definition”int64_t float_compare ( int64_t float1, int64_t float2, uint32_t mode);
function float_compare( f1: bigint, f2: bigint, mode: number ): ErrorCode | number
Example
Section titled “Example”if (float_compare(pusd_to_send, 0, COMPARE_LESS) == 1){ // pusd_to_send is less than 0}
if (float_compare(pusd_to_send, 0n, COMPARE_LESS) == 1){ // pusd_to_send is less than 0}
Parameters
Section titled “Parameters”Name | Type | Description |
---|---|---|
float1 | int64_t | An XFL floating point enclosing number representing the first operand to the comparison |
float2 | int64_t | An XFL floating point enclosing number representing the second operand to the comparison |
mode | uint32_t | A bit-flag field consisting of any of (or any logically valid combination of) the following flags:COMPARE_LESS COMPARE_EQUAL COMPARE_GREATER Valid combinations are: COMPARE_LESS |
Name | Type | Description |
---|---|---|
f1 | bigint | The first float to compare. |
f2 | bigint | The second float to compare. |
mode | number | The comparison mode (e.g., less than, equal to, greater than). |
Return Code
Section titled “Return Code”Type | Description |
---|---|
int64_t | 0 if the comparison was logically false.1 if the comparison was logically true.If negative, an error: INVALID_FLOAT - one of the supplied parameters was not a valid XFL enclosing number INVALID_ARGUMENT - invalid combination of supplied comparison flags. |
Type | Description |
---|---|
ErrorCode or number | Returns an error code or the comparison result as a number. |