Direct Base-to-Base Conversion Algorithm: Integer and Fractional Parts with Array-Based Arithmetic
This paper introduces a direct, precise base-to-base conversion algorithm for numbersin arbitrary bases from 2 to 62, eliminating the need for intermediate decimal conversions.Unlike traditional approaches which convert through base 10 and suffer from floating-pointrounding errors, our method employs array-based big integer arithmetic to maintain exactprecision for both integer and fractional parts simultaneously. The algorithm processesdigits from the source base one by one with inline normalization to the target base,avoiding floating-point operations altogether. We provide formal pseudocode for bothinteger and fractional parts, complexity analyses, and practical guidance for safedata-type selection. The integer conversion runs in O(n · m) time and fractional conversion in O(d · p),where n, m represent the count of source and target integer digits and d, p the sourcefractional digits and desired fractional precision. An open-source C++ implementationis available on GitHub. This approach enables exact, efficient conversions suitablefor high-precision and arbitrarily large numeric data in modern computational applications.
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2025-12-02
- DOI
- https://doi.org/10.5281/zenodo.17790079
- Primary Topic
- Numerical Methods and Algorithms
- Type
- article
- Field-Weighted Citation Impact
- 0.00