Convert an XFL floating point into an integer (floor)

Concepts

Behaviour

  • Left shift (multiply by 10) the XFL by the number of specified decimal places
  • Convert the resulting XFL to an integer, discarding any remainder
  • Return the integer

Definition

int64_t float_int (
    int64_t float1,
    uint32_t decimal_places,
    uint32_t absolute
);

Example

int64_t drops =
    float_int(xrpbalance, 6, 0);

Parameters

Name

Type

Description

float1

int64_t

An XFL floating point enclosing number representing the first operand to the addition

decimal_places

uint32_t

The number of places to shift the decimal to the right before computing the floor of the floating point.

absolute

uint32_t

If 1 also take the absolute of the value before returning it.

📘

Hint

Negative return values are reserved for error codes. Therefore if you need to execute this function against a negative XFL you should use absolute = 1

Return Code

Type

Description

int64_t

The computed positive integer

If negative, an error:
INVALID_FLOAT

  • one of the supplied parameters was not a valid XFL enclosing number

INVALID_ARGUMENT

  • attempted to specify more than 15 decimal places.

CANT_RETURN_NEGATIVE

  • attempted to return a negative integer but this is not allowed, use absolute = 1