Thanks to the folks at CCIL for hosting these pages.
remlaPS Home Page remlaPS Web Logs at CCIL

Integer Base Conversion Tool

This page contains a proof of concept demo and code for some integer base (radix) conversion algorithms. The algorithms used are crudely described in Alternative Algorithms for Integer Base Conversion. DispConWeb is a web based java calculator for integer base conversion. It handles positive integers in positive and negative bases from base -94 through 94, except for bases -1, 0 and 1.

Here are the values for the digits used...
0         1         2         3         4         5         6         7         8         9
0123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123
0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+[]{}\|;:,.<>/?'"
Here is the java applet...

Notes:

  • 'A' and 'a' have different values (10 and 36) as do all upper/lower case alpha character pairs.
  • There is very little validation, so it's up to you to avoid overflows.
  • Positive integers only...
    • The dot ('.') is the 89th digit (value=88 if abs(base) > 89), not a radix point.
    • Numerals which start with a dash ('-') start with the 74th digit. They are not negative.
    • Numbers in negative bases are negative if their number of digits is even.
  • Bases which start with a dash ('-') ARE negative.

Source:

DispConWeb.java - Applet I/O and error checking stuff.
Normalize.java - Inbase is a multiple/factor of outbase.
PascalT.java - Convert between bases by an additive offset, using Pascal's Triangle.

Local Version:

DispCon (stale and gettting staler 6/9/7)


Update: Replaced "Reset" logic with a function and modified to accept <Return> in addition to press of "Convert" button. 7/14/7
Update: Integer type verification for input base and output base. 7/15/7.

Author: Steve Palmer (remlaps@ccil.org)

June 1, 2007
Revised June 9, 2007