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

Create a float from an exponent and mantissa

Concepts

Behaviour

  • Compute an XFL (xls17) floating point from the provided exponent and mantissa
  • Return that XFL as an int64_t

Definition

int64_t float_set (
    int32_t exponent,
    int64_t mantissa
);

Example

int64_t small_amount =
  float_set(-81, 1);

Parameters

NameTypeDescription
exponentint32_tAn exponent in the range -96 to 80
mantissaint64_tA mantissa. If negative then the sign of the float is negative.

🚧

Caution

When setting a mantissa that is greater or fewer than 16 decimal digits the exponent will be adjusted to ensure the mantissa is exactly 16 digits. This adjustment may result in an INVALID_FLOAT in some circumstances.

📘

Special case

XFL canonical 0 is also 0 in the enclosing number. Thus there is never a need to call float_set(0,0);

Return Code

TypeDescription
int64_tThe XFL (xls17) enclosing number

If negative, an error:
INVALID_FLOAT
- The adjustment of the mantissa to 16 digits produced an under or overflow.