class Digit

  attr_accessor :value

  def initialize( x )
    if x =~ /^0x/
      @value = x.oct
    else
      @value = x.to_i
    end
  end

  def to_s( n=10 )
    if n == 16
      '0x%X' % @value
    else
      @value.to_s
    end
  end

end
