Skip to content

IntTryFromStr

Description

Parse a decimal string into an integer. An optional leading + is accepted.

Usage example (Cross-references)

Usage examples (Cross-references)
        }
    
        if (!IntTryFromStr(&result.significand, digits.data)) {
            goto fail;
        }
    }
    
    bool IntTryFromStr(Int *out, const char *decimal) {
        u64 start = 0;
        Int out = IntInit();
    
        (void)IntTryFromStr(&out, decimal);
        return out;
    }
        Int parsed = IntFromStr("12x3");
        Int value  = IntInit();
        bool result = !IntTryFromStr(&value, "12x3");
    
        result = result && IntIsZero(&parsed);
        Int parsed = IntFromStr(NULL);
        Int value  = IntInit();
        bool result = !IntTryFromStr(&value, NULL);
    
        result = result && IntIsZero(&parsed);
Last updated on