Skip to content
ZstrHexDigitValue

ZstrHexDigitValue

Description

Convert a hex / decimal digit character to its numeric value. Accepts 0..9, a..f, A..F (case-insensitive for hex).

Success

Returns the digit value 0..15.

Failure

Returns -1 when c is not a valid hex / decimal digit.

Usage example (Cross-references)

Usage examples (Cross-references)
    }
    
    int ZstrHexDigitValue(char c) {
        if (c >= '0' && c <= '9') {
            return c - '0';
    #if FEATURE_INT
    static bool int_fmt_digit_matches_radix(char c, u8 radix) {
        int digit = ZstrHexDigitValue(c);
    
        return digit >= 0 && digit < radix;
Last updated on