float_sto
Concepts
Section titled “Concepts”Behaviour
Section titled “Behaviour”- Read an XFL floating point number and optionally a field code and currency code
- Write a serialized amount to
write_ptraccording to the parameters provided
- Stores a float representation into a specified field.
- Returns an error code or the updated value as an array of numbers.
Definition
Section titled “Definition”int64_t float_sto ( uint32_t write_ptr, uint32_t write_len, uint32_t cread_ptr, uint32_t cread_len, uint32_t iread_ptr, uint32_t iread_len, int64_t float1, uint32_t field_code);function float_sto( currency: ByteArray | HexString | undefined, issuer: ByteArray | HexString | undefined, f1: bigint, field_code: number ): ErrorCode | ByteArrayExample
Section titled “Example”#define SBUF(str) (uint32_t)(str), sizeof(str)uint8_t amt_out[48];if (float_sto(SBUF(amt_out), SBUF(currency), SBUF(hook_accid), pusd_to_send, -1) < 0) rollback(SBUF("Peggy: Could not dump pusd amount into sto"), 1);const amt_out = float_sto(currency, hook_accid, pusd_to_send, -1)if (typeof amt_out === 'number') rollback("Peggy: Could not dump pusd amount into sto", 1)Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| write_ptr | uint32_t | Pointer to a buffer of a suitable size to store the serialized amount field. Recommend at least 48 bytes. |
| write_len | uint32_t | The length of the output buffer. |
| cread_ptr | uint32_t | Pointer to a buffer contianing the currency code to serialize into the output. May be null. |
| cread_len | uint32_t | The length of the currency code. This must be 20 or 3 or 0 (null). |
| iread_ptr | uint32_t | Pointer to a buffer containing the issuer’s Account ID to serialize into the output. May be null. |
| iread_len | uint32_t | The length of the issuer’s Account ID. This must be either 20 or 0 (null). |
| float1 | int64_t | An XFL floating point enclosing number to serialize. |
| field_code | uint32_t | The |
| Name | Type | Description |
|---|---|---|
| currency | ByteArray | HexString | undefined | The current value to store into. |
| issuer | ByteArray | HexString | undefined | The value to store. |
| f1 | bigint | The field code indicating where to store the float. |
| field_code | number | An error code or the updated value as an array of numbers. |
Return Code
Section titled “Return Code”| Type | Description |
|---|---|
| int64_t | The number of bytes written to the output buffer. |
| Type | Description |
|---|---|
| ErrorCode | ByteArray | Returns an error code or the updated value as an array of numbers. |