Numeric-to-text conversion¶
This operation converts a signed integer amount into its English-words representation (e.g., for printed check or dollar amounts), recursively decomposing the value into magnitude groups and concatenating the words for each group with the appropriate magnitude label.
| Field | Value |
|---|---|
| Operation ID | OP-BU-02 |
| Trigger | Caller calls mdlTextConversion.NumberToText(n) |
| Inputs | n As Long |
| Outputs | String (English-words representation of n) |
| Primary components | mdlTextConversion.NumberToText, mdlTextConversion.RoundDown |
| Entry point | Business\SAIF.Business.Utilities\mdlTextConversion.vb |
Steps¶
- Validate the upper bound. If
nexceeds999,999,999,999,999, throwApplicationException("Number too large to convert to text. Limit is 999,999,999,999,999."). (BR-002) - On failure: the exception propagates to the caller; no partial result is returned.
- Handle negative values. If
nis less than zero, prefix the result with"Minus "and recursively convert the absolute value (-n). - Handle the zero case. If
nequals zero, return an empty string (used as the recursion base case for magnitude groups with no remainder). - Convert ones and teens (1–19). Look up the value in a fixed array of number words ("One" through "Nineteen").
- Convert tens (20–99). Look up the tens digit in a fixed array of tens words ("Twenty" through "Ninety") using
RoundDown(n, 10) - 2as the index, and recursively convert and append the remainder (n Mod 10). - Convert hundreds (100–999). For 100–199, prefix
"One Hundred "and recursively convert the remainder (n Mod 100); for 200–999, recursively convert the hundreds digit, append"Hundred ", and recursively convert the remainder. - Convert thousands, millions, billions, and trillions, following the same pattern at each magnitude: a
1999-style band prefixes"One <Magnitude> "and recursively converts the remainder; the general band recursively converts the leading digits (viaRoundDown), appends the magnitude label ("Thousand ","Million ","Billion ","Trillion "), and recursively converts the remainder. - Return the concatenated result. The recursive calls build up the final words string, which is returned to the caller with a trailing space after each word group.*
Process flow¶
The following diagram visualizes the magnitude-band recursion used by this operation.
flowchart TD
Start([Start: NumberToText n]) --> Bound{n exceeds<br>999,999,999,999,999?}
Bound -->|Yes| Ex([Throw ApplicationException])
Bound -->|No| Neg{n less than 0?}
Neg -->|Yes| Minus["Prefix 'Minus '<br>recurse on -n"]
Neg -->|No| Zero{n equals 0?}
Zero -->|Yes| Empty([Return empty string])
Zero -->|No| Band{Which magnitude band?}
Band -->|1-19| Ones[Look up in ones/teens array]
Band -->|20-99| Tens[Look up tens word,<br>recurse on remainder]
Band -->|100-999| Hundreds[Recurse on hundreds digit,<br>append 'Hundred',<br>recurse on remainder]
Band -->|Thousands/Millions/<br>Billions/Trillions| Magnitude[Recurse on leading digits,<br>append magnitude label,<br>recurse on remainder]
Ones --> Return([Return concatenated words])
Tens --> Return
Hundreds --> Return
Magnitude --> Return
Minus --> Return
Failure and edge-case behavior¶
ngreater than999,999,999,999,999throwsApplicationExceptionrather than returning a partial or truncated result. (BR-002)- Negative numbers are supported via a
"Minus "prefix and recursion on the absolute value; there is no explicit lower-bound guard symmetrical to the upper-bound check.* - Zero returns an empty string rather than the word "Zero" — this is relied upon as the recursion base case for magnitude groups with no remainder, but also means a top-level call with
n = 0returns an empty string rather than a descriptive word.*
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Related documentation¶
Sources¶
Business\SAIF.Business.Utilities\mdlTextConversion.vb