Parse number as fixed point according to JSON number syntax.

Synopsis

Declared in <util/strencodings.h>

[[nodiscard]]
bool
ParseFixedPoint(
    std::string_view val,
    int decimals,
    int64_t* amount_out);

Description

Note

The result must be in the range (‐10ˆ18,10ˆ18), otherwise an overflow error will trigger.

Return Value

true on success, false on error.

Note

The return value should not be discarded.

Parameters

Name

Description

val

The string to parse.

decimals

Number of digits after the decimal point in the fixed‐point result.

amount_out

Set to the parsed value scaled by 10ˆdecimals on success.

Created with MrDocs