BaseNConverter¶
BaseNConverter is a public VB Module that exposes fluent extension methods for converting between BaseN strings and decimal values against any IConverter implementation, decoupling callers from a converter's internal digit-array plumbing.
Purpose¶
- Provide the fluent, extension-method-based public API (
BaseNToDecimal,DecimalToBaseN) for this library's base-N conversion functionality.
Context¶
- Namespace:
SAIF.Framework.BaseN - Assembly/package:
SAIF.Framework.BaseN(also bundled into theSAIF.BOF.FrameworkNuGet package)
Public members¶
| Member | Signature | Purpose |
|---|---|---|
BaseNToDecimal |
<Extension()> Public Function BaseNToDecimal(ByVal value As String, ByVal converter As IConverter) As Long |
Extension method on String; converts a BaseN string to its decimal (Long) value using the supplied converter (e.g., "101".BaseNToDecimal(New BinaryConverter()) returns 5). |
DecimalToBaseN |
<Extension()> Public Function DecimalToBaseN(ByVal input As Long, ByVal converter As IConverter) As String |
Extension method on Long; converts a decimal value to its BaseN string representation using the supplied converter. |
DecimalToBaseN (overload) |
<Extension()> Public Function DecimalToBaseN(ByVal input As Integer, ByVal converter As IConverter) As String |
Extension method on Integer; overload that delegates to the Long overload via CLng(input). |
Behavioral notes¶
BaseNToDecimalconverts each character of the input string to a numeric digit viaconverter.ConvertAlphaToNumeric, then sumsdigit * Base^positionright-to-left (private helpersConvertToNumericArray,ConvertBaseNToDecimal).DecimalToBaseNrecursively divides the input byconverter.Base, building a comma-separated alpha digit list viaconverter.ConvertNumericToAlpha(private helperConvertDecimalToBaseN), then re-tokenizes it into a digit array and callsconverter.FormatBaseNto produce the final string.- Private helper methods (
ConvertBaseNToDecimal,ConvertDecimalToBaseN,ConvertToNumericArray) are internal implementation details and are not part of the public API.
Constraints and usage notes¶
- As VB extension methods, these members require an
Importsof the containing namespace (SAIF.Framework.BaseN) and are invoked using instance-method syntax onString/Long/Integervalues. - Any
ConverterExceptionthrown by the suppliedconverter(e.g.,HexConverter,ExcelConverter) propagates to the caller ofBaseNToDecimal/DecimalToBaseNuncaught.*
Note: Statements marked with * were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts. Statements marked with ** could not be confirmed; treat as unknown until verified. Statements marked with † were retrieved from dependency library documentation via the Legends CLI RAG service. They describe inherited behavior from the indicated origin library and should be verified if the dependency version changes.
Sources¶
SAIF.Framework.BaseN\BaseNConverter.vb