---
title: float_mulratio
description: Multiply an XFL floating point by a non-XFL numerator and denominator
---
import { Tabs, TabItem, LinkButton, Aside } from '@astrojs/starlight/components';

### Concepts

<LinkButton href="/docs/hooks/concepts/floating-point-numbers-xfl">Floating Point Numbers (XFL)</LinkButton>

### Behaviour

<Tabs>
<TabItem label="C">
* Compute the multiplication of an XFL (xls17) floating point number and the quotient of two integers
* Return a new XFL as an int64_t
</TabItem>

<TabItem label="JavaScript">
* Multiplies a float by a ratio defined by a numerator and denominator.
* Returns an error code or new XFL as a bigint.
</TabItem>
</Tabs>

### Definition

<Tabs>
<TabItem label="C">
```c
int64_t float_mulratio (
    int64_t float1,
    uint32_t round_up,
    uint32_t numerator,
    uint32_t denominator
);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
function float_mulratio(
    f1: bigint,
    round_up: number,
    numerator: number,
    denominator: number
  ): ErrorCode | bigint
```
</TabItem>
</Tabs>



### Example

<Tabs>
<TabItem label="C">
```c
int64_t max_vault_pusd =
    float_mulratio(max_vault_pusd, 0,
        COLLATERALIZATION_NUMERATOR, COLLATERALIZATION_DENOMINATOR);
```
</TabItem>

<TabItem label="JavaScript">
```javascript
const max_vault_pusd =
    float_mulratio(max_vault_pusd, 0,
        COLLATERALIZATION_NUMERATOR, COLLATERALIZATION_DENOMINATOR);
```
</TabItem>
</Tabs>



### Parameters

<Tabs>
<TabItem label="C">
| Name        | Type      | Description                                                                                 |
| ----------- | --------- | ------------------------------------------------------------------------------------------- |
| float1      | int64_t  | An XFL floating point enclosing number representing the first operand to the multiplication |
| round_up   | uint32_t | If non-zero all computations will be rounded up                                             |
| numerator   | uint32_t | The numerator of the quotient that the float will be multiplied by                          |
| denominator | uint32_t | The denominator of the quotient that the float will be multiplied by                        |

<Aside type="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).
</Aside>
</TabItem>

<TabItem label="JavaScript">


| Name        | Type   | Description                                                                                 |
| ----------- | ------ | ------------------------------------------------------------------------------------------- |
| f1          | bigint | An XFL floating point enclosing number representing the first operand to the multiplication |
| round_up   | number | If non-zero all computations will be rounded up                                             |
| numerator   | number | The numerator of the quotient that the float will be multiplied by                          |
| denominator | number | The denominator of the quotient that the float will be multiplied by                        |
</TabItem>
</Tabs>



### Return Code

<Tabs>
<TabItem label="C">
| Type     | Description                                                                                                                                                                                                                                                                                                                                                    |
| -------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| int64_t | <p>The XFL (xls17) enclosing number<br /><br />If negative, an error:<br /><code>INVALID_FLOAT</code><br />- one of the supplied parameters was not a valid XFL enclosing number<br /><br /><code>OVERFLOW</code><br />- the result of the multiplication was too large to store in an XFL.<br /><br /><code>DIVISION_BY_ZERO</code><br />- the supplied denominator was zero.</p> |


</TabItem>

<TabItem label="JavaScript">


| Type                | Description                                                 |
| ------------------- | ----------------------------------------------------------- |
| ErrorCode or bigint | Returns an error code or tThe XFL (xls17) enclosing number. |
</TabItem>
</Tabs>

