FWIW, all values โโare actually in base 2 inside your machine (I'm sure you already knew that). It only appears as base 10, because string conversion creates string representations in base 10 (for example, when printing), because methods like parseLong assume that the input string is in base 10 and because the compiler expects everything literals will be in base 10 when you actually write code. In other words, everything is in binary form, the computer only converts the material to and from base 10 for the convenience of people.
It follows that we should easily change the source base to something other than 10, and therefore get string representations for the same value in base 9. In Java, this is done by passing an optional additional base parameter to Long.toString .
long x=10; System.out.println(Long.toString(x,9));
source share