Converting Between ENS and ANS Integers

ENS = Existing Number System
ANS = Alternate Number System

Several people have asked me to describe an easy way to convert between
integers in ENS and ANS.  I will try to explain the procedure I use using
base ten, however the procedure works equally well with other bases>1.

Remember that in base ten, ENS digits are : 0,1,2,3,4,5,6,7,8,9
                           ANS digits are : 1,2,3,4,5,6,7,8,9,A
                           where "A" represents the digit ten.

So the only difference between ENS and ANS, is that ENS has the digit 0, and
ANS has the digit A (ten).

Given a number in ENS, start at the leftmost digit, and locate the first 
zero digit.  Borrow one from the digit to its immediate left, and change the 
zero digit to A. Carry on this process until the number has no more zero 
digits left.

The reverse procedure is:
Given a number in ANS, start again at the leftmost digit, and locate the 
first ten digit (A).  Add one to the digit to its immediate left, and change
the A digit to zero. Carry on this process until the number has no more
A digits left.

Examples:

Converting ENS to ANS                 Converting ANS to ENS

ENS = 1240301                         ANS = 123A2A1
    = 123A2A1 = ANS                       = 1240301 = ENS

ENS = 20030                           ANS = 19A2A
    = 1A02A                               = 1A030
    = 19A2A = ANS                         = 20030 = ENS

ENS = 2000                            ANS = 199A
    = 1A00                                = 19A0
    = 19A0                                = 1A00
    = 199A = ANS                          = 2000 = ENS
      
ENS = 1010                            ANS =  9AA
    =  A0A                                =  A0A
    =  9AA = ANS                          = 1010 = ENS

ENS = 10000                           ANS =  999A
    =  A000                               =  99A0
    =  9A00                               =  9A00
    =  99A0                               =  A000
    =  999A = ANS                         = 10000 = ENS

ENS = 1001001                         ANS =  99A9A1
    =  A00A01                             =  9A0A01
    =  9A09A1                             =  A01001
    =  99A9A1 = ANS                       = 1001001 = ENS

ENS = 10110110                        ANS =  9AA9AAA
    =  A10A10A                            =  A0AA0AA
    =  A0AA0AA                            = 1010A10A 
    =  9AA9AAA = ANS                      = 10110110 = ENS

Practice more on your own, and soon you will easily be able to convert any 
numbers from ENS to ANS and back.

Enjoy.

Return to the Main Menu

Last modified Sep.29 1997