These docs are for v2.0. Click to read the latest docs for v3.0.

Multiply an XFL floating point by a non-XFL numerator and denominator

Concepts

Behaviour

  • Compute the multiplication of an XFL (xls17) floating point number and the quotient of two integers
  • Return a new XFL as an int64_t

Definition

int64_t float_multiply (
    int64_t float1,
    uint32_t round_up,
    uint32_t numerator,
    uint32_t denominator
);

Example

int64_t max_vault_pusd =
    float_mulratio(max_vault_pusd, 0,
        COLLATERALIZATION_NUMERATOR, COLLATERALIZATION_DENOMINATOR);

Parameters

NameTypeDescription
float1int64_tAn XFL floating point enclosing number representing the first operand to the multiplication
round_upuint32_tIf non-zero all computations will be rounded up
numeratoruint32_tThe numerator of the quotient that the float will be multiplied by
denominatoruint32_tThe denominator of the quotient that the float will be multiplied by

🚧

Caution

Certain multiplications may overflow, which return with an INVALID_FLOAT error. However an underflow returns as XFL Canonical Zero (i.e. enclosing number = 0).

Return Code

TypeDescription
int64_tThe XFL (xls17) enclosing number

If negative, an error:
INVALID_FLOAT
- one of the supplied parameters was not a valid XFL enclosing number

OVERFLOW
- the result of the multiplication was too large to store in an XFL.

DIVISION_BY_ZERO
- the supplied denominator was zero.