Direct Base-to-Base Conversion Algorithm: Integer and Fractional Parts with Array-Based Arithmetic

Read the full article See related articles

Discuss this preprint

Start a discussion What are Sciety discussions?

Listed in

This article is not in any list yet, why not save it to one of your lists.
Log in to save this article

Abstract

This paper introduces a direct, precise base-to-base conversion algorithm for numbers in 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-point rounding errors, our method employs array-based big integer arithmetic to maintain exact precision for both integer and fractional parts simultaneously. The algorithm processes digits from the source base one by one with inline normalization to the target base, avoiding floating-point operations altogether. We provide formal pseudocode for both integer and fractional parts, complexity analyses, and practical guidance for safe data-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 source fractional digits and desired fractional precision. An open-source C++ implementation is available on GitHub. This approach enables exact, efficient conversions suitable for high-precision and arbitrarily large numeric data in modern computational applications.

Article activity feed