# Printing the base 'b' value of an integer as a string (without the subscript base indication)

Is there a simple one-liner to convert a given base 10 integer to a string representation of this integer in some desired base 'b'? Is there a way to do this avoiding the subscript indicating the base, for example the small 2 if we ask for a binary string?

The best thing for my purpose, despite the danger, would be have a function that takes a decimal integer and returns what appears to be the binary, ternary, etc. representation of this integer, but which Mathematica still treats as a decimal integer value.

There's a built-in to do just this, e.g.:

IntegerString[125, 2]
IntegerString[125, 16]

(*
1111101
7d
*


I think what you are looking for is a function that, for example takes the number fifteen and the base two, writes 15 in base 2 (which is 1111) and then returns the value one thousand, eleventy one (base 10).

If that's what you're aiming at, then what you are looking for is

f[number_, base_] := FromDigits[IntegerDigits[number, base]]


where base says what the intermediate base you want to filter your number through should be.

(*
In:= f[15, 2]

Out= 1111
*)

StringJoin @@ ToString /@ IntegerDigits[105, 3]

"10220"

FromDigits[ToExpression@Characters[%], 3]

105

• @Kuba: can you point me to a FAQ where I can learn the standards of prefered layout? – Wouter Apr 3 '14 at 19:06
• Here's the markdown info. But about "output" there isn't best way. this is the one I'm using :) – Kuba Apr 3 '14 at 19:09