Subato

Zahlendarstellungen

class Num{
  final long n;
  Num(long n){
    assert n>=0;
    this.n = n;
  }
  String toBin(){
    return n==0?"0":(new Num(n/2).toBin()+n%2); 
  }
  String toOct(){
    return n==0?"0":(new Num(n/8).toOct()+n%8);
  }
  static char getDigit(long d){
    return (char) (d<10? '0'+d : 'A'+d-10);
  }  
  String toBase(int b){
    return n==0?"0":(new Num(n/b).toBase(b)+getDigit(n%b));
  }      
}