Microsoft KB Archive/69777

{| = Macro to Convert Decimal Number to a Different Base =
 * width="100%"|

Last reviewed: November 2, 1994

Article ID: Q69777

SUMMARY
Below is a function macro to convert an integer number to any base less than 10

=baseconv(number,base) where &quot;number&quot; is the decimal number to be converted, and &quot;base&quot; is the number of the base to convert &quot;number&quot; to. After you type the following information, select cell A1 and define the macro to be a function macro, using the Define Name command under the Formula menu:

A1 =baseconv A2 =ARGUMENT(&quot;input&quot;,2) A3 =ARGUMENT(&quot;base&quot;,2) A4 =SET.NAME(&quot;quotient&quot;,input) A5 =SET.NAME(&quot;remainder&quot;,input) A6 =SET.NAME(&quot;answer&quot;,&quot;&quot;) A7 =WHILE(quotient<>0) A8 =SET.NAME(&quot;remainder&quot;,MOD(quotient,base)) A9 =SET.NAME(&quot;quotient&quot;,TRUNC(quotient/base)) A10 =SET.NAME(&quot;answer&quot;,remainder&answer) A11 =NEXT A12 =RETURN(VALUE(answer)) Now the function macro is ready to use. Below is an example of how to type the function on your worksheet: =baseconv(100,2) would return 1100100.
 * }