---
title: Convert alpha digit to numeric value
summary: Resolves a single input token to its numeric digit value for the active converter.
status: draft
owner: SAIF DocGen
last_reviewed: 2026-07-30
library: SAIF.Framework.BaseN
reference_type: package
operation_id: OP-BASEN-004
trigger: Decode flow, encode re-tokenization, or direct `IConverter.ConvertAlphaToNumeric` invocation.
---

# 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

1. The input token arrives through `IConverter.ConvertAlphaToNumeric`.
2. The call dispatches to whichever converter implementation is active.
3. `ConverterBase` checks `IsNumeric(input)`:
   - If true, it returns `CInt(input)`.
   - If false, it returns `0` without raising an exception ([BR-004](../business-rules.md#br-004-non-numeric-input-to-the-default-alpha-to-numeric-conversion-is-treated-as-zero)).
4. `HexConverter` branches on the token's shape:
   - Numeric input greater than `16` raises `ConverterException` ([BR-001](../business-rules.md#br-001-hexadecimal-digit-must-not-exceed-base-16)).
   - Numeric input within range is returned directly.
   - Non-numeric input is uppercased and mapped from `A`-`F` to `10`-`15`.
   - Any other non-numeric token raises `ConverterException` ([BR-001](../business-rules.md#br-001-hexadecimal-digit-must-not-exceed-base-16)).
5. `ExcelConverter` initializes `output = -1` and 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`, `ConverterException` is raised ([BR-002](../business-rules.md#br-002-excel-base-26-digit-must-not-exceed-base-26)).
   - A token longer than one character bypasses conversion entirely and returns the initialized `-1`.
6. The resolved numeric value is returned to the caller.

## Process flow

The following diagram visualizes this operation's control flow.

```mermaid
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

- `ConverterBase` returns `0` for non-numeric input instead of failing; this is the default that `BinaryConverter` and `OctalConverter` rely on rather than override ([BR-004](../business-rules.md#br-004-non-numeric-input-to-the-default-alpha-to-numeric-conversion-is-treated-as-zero)).
- `HexConverter` rejects alphabetic input outside `A`-`F` and numeric values greater than `16` ([BR-001](../business-rules.md#br-001-hexadecimal-digit-must-not-exceed-base-16)).
- `ExcelConverter` converts only single-character input; multi-character tokens skip the conversion branch entirely and return the initialized `-1` sentinel value.
- `ExcelConverter` accepts lowercase letters transparently because it normalizes input with `ToUpper` before mapping.

## Related documentation
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)

## Sources
- `SAIF.Framework.BaseN\ConverterBase.vb`
- `SAIF.Framework.BaseN\BinaryConverter.vb`
- `SAIF.Framework.BaseN\OctalConverter.vb`
- `SAIF.Framework.BaseN\HexConverter.vb`
- `SAIF.Framework.BaseN\ExcelConverter.vb`

