Convert alpha digit to numeric value¶
This operation maps a single input token to the numeric digit value the active converter expects. The shared base implementation is permissive and never fails; the hex and Excel converters add their own alphabetic mappings and bounds enforcement on top.
| Field | Value |
|---|---|
| Operation ID | OP-BASEN-004 |
| Trigger | Converter digit-decoding request |
| Inputs | String token |
| Outputs | Integer digit value |
| Primary components | ConverterBase.ConvertAlphaToNumeric, HexConverter.ConvertAlphaToNumeric, ExcelConverter.ConvertAlphaToNumeric |
| Entry point | SAIF.Framework.BaseN\ConverterBase.vb |
Steps¶
- The input token arrives through
IConverter.ConvertAlphaToNumeric. - The call dispatches to whichever converter implementation is active.
ConverterBasechecksIsNumeric(input):- If true, it returns
CInt(input). - If false, it returns
0without raising an exception (BR-004). HexConverterbranches on the token's shape:- Numeric input greater than
16raisesConverterException(BR-001). - Numeric input within range is returned directly.
- Non-numeric input is uppercased and mapped from
A-Fto10-15. - Any other non-numeric token raises
ConverterException(BR-001). ExcelConverterinitializesoutput = -1and only attempts conversion when the token is exactly one character long:- A numeric one-character token is returned directly.
- An alphabetic one-character token is uppercased and mapped with
Asc(input.ToUpper) - 64. - If that mapped value exceeds
26,ConverterExceptionis raised (BR-002). - A token longer than one character bypasses conversion entirely and returns the initialized
-1. - The resolved numeric value is returned to the caller.
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([ConvertAlphaToNumeric called]) --> D1{Converter type}
D1 -->|Base/Binary/Octal| S1[Parse numeric or return 0]
D1 -->|Hex| S2[Parse numeric or map A-F]
D1 -->|Excel| S3[Require one character and map A-Z]
S1 --> EndOk([Return integer digit])
S2 --> D2{Invalid token?}
D2 -->|Yes| EndErr([Raise ConverterException])
D2 -->|No| EndOk
S3 --> D3{Value > 26?}
D3 -->|Yes| EndErr
D3 -->|No| EndOk
Failure and edge-case behavior¶
ConverterBasereturns0for non-numeric input instead of failing; this is the default thatBinaryConverterandOctalConverterrely on rather than override (BR-004).HexConverterrejects alphabetic input outsideA-Fand numeric values greater than16(BR-001).ExcelConverterconverts only single-character input; multi-character tokens skip the conversion branch entirely and return the initialized-1sentinel value.ExcelConverteraccepts lowercase letters transparently because it normalizes input withToUpperbefore mapping.
Related documentation¶
Sources¶
SAIF.Framework.BaseN\ConverterBase.vbSAIF.Framework.BaseN\BinaryConverter.vbSAIF.Framework.BaseN\OctalConverter.vbSAIF.Framework.BaseN\HexConverter.vbSAIF.Framework.BaseN\ExcelConverter.vb