decimalValue function

int decimalValue(
  1. int codeUnit
)

The value of a single decimal character, 0-9. Anything else gives -1, so a number built out of junk fails validation downstream instead of throwing here.

Implementation

int decimalValue(int codeUnit) =>
    codeUnit >= _asciiZero && codeUnit <= _asciiNine ? codeUnit - _asciiZero : -1;