Perform a comparison on two XFL floating point numbers
Concepts
Behaviour
- Evaluate a comparison of two XFL floating point numbers
- Return the result of the comparison as a boolean encoded in an int64_t.
Definition
int64_t float_compare (
int64_t float1,
int64_t float2,
uint32_t mode
);
Example
if (float_compare(pusd_to_send, 0, COMPARE_LESS) == 1)
{
// pusd_to_send is less than 0
}
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 | COMPARE_GREATER - Not equal COMPARE_LESS | COMPARE_EQUAL - Less than or equal to COMPARE_GREATER | COMPARE_EQUAL - Greater than or equal to |
Caution
Always verify the function returned
1
rather thannon-zero
, as negative error codes will be classed asnon-zero
.
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. |