Hi - can you adapt the following to do what you need?
// Function to convert an integer into any positive base up to hexadecimal;
base = Function( {n, nbase}, {default local},
ndash = "";
digits= "0123456789ABCDEF";
While( n > 0,
remainder= Mod( n, nbase );
newdigit= Substr( digits, (1 + remainder), 1 );
ndash= newdigit || ndash;
n= (n - remainder)/ nbase;
);
ndash;
);
// Print out a few numbers to show it working in binary;
For( i = 1, i <= 32, i++, Show( Char( i ) || " = " || base( i, 2 ) ) );
// Or create some new columns in a data table and fill them;
dt = New Table( "Number Bases", New Column( "N", numeric, values( Index( 1, 32 ) ) ) );
numberbase = {2, 3, 8, 10, 12, 16}; // Some familiar number bases;
For( i = 1, i <= N Items( numberbase ), i++,
k= numberbase[i];
dt<< New Column( "Base "|| Char( k ), character );
For( j = 1, j <= N Row( dt ), j++,
Column( dt, ("Base "|| Char( k )) )[j] = base( j, k ) );
);
// End of program;