Return the digit value of character in base, or ‐1 if invalid.

Synopsis

Declared in <bdlb_numericparseutil.h>

static
int
characterToDigit(
    char character,
    int base);

Description

Determine whether the specified character represents a digit in the specified base; return the numeric equivalent if so, and ‐1 otherwise. The behavior is undefined if either character or base is 0 and unless 2 <= base and base <= 36 (i.e., bases where digits are representable by characters in the range [`0`‐`9`], [`a`‐`z`], or [`A`‐`Z`]).

Return Value

digit value in [0 .. base)], or ‐1 if character is not a valid digit in base

Parameters

Name

Description

character

character to interpret as a digit

base

numeric base in [2 .. 36]

Created with MrDocs