ParseFixedPoint

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

NameDescription
valThe string to parse.
decimalsNumber of digits after the decimal point in the fixed-point result.
amount_outSet to the parsed value scaled by 10^decimals on success.