Skip to content

ZstrToF64

Description

Parse a decimal floating-point value. Accepts [+-]?digits(.digits)?([eE][+-]?digits)?. Used by JSON / KvConfig numeric values where bit-exactness on long mantissas is not required.

Success

Returns the parsed value as f64.

Failure

Returns 0.0 when no digits are present.

Usage example (Cross-references)

Usage examples (Cross-references)
            return false;
        Zstr end = NULL;
        f64  v   = ZstrToF64(s, &end);
        if (!end || end == s || *end != '\0')
            return false;
    }
    
    f64 ZstrToF64(Zstr s, Zstr *endptr) {
        if (!s) {
            if (endptr)
        }
    
        parsed = ZstrToF64(StrBegin(value), &endptr);
    
        if (!endptr || endptr == StrBegin(value) || *endptr != '\0') {
        Zstr end = NULL;
        if (is_flt) {
            num->f = ZstrToF64(StrBegin(&ns), &end);
        } else {
            num->i = ZstrToI64(StrBegin(&ns), &end);
Last updated on