This was just an example to play with since you asked
for a #convertFromBase:to: method in your original mail 
and one cant provide such a method on Number. Your 
original request

  11 convertFromBase: 2 to: 10

may work - but it wont work for hex values:

  FF convertFromBase: 16 to: 10

then FF would have to be a string.

  'FF' convertFromBase: 16 to: 10

So having a #convertFromBase:to: on String is not to recommend
(especially since the string has to be in a number format)
and also not necessary. I should have added this to my mail
as a warning.

Just use

   (Number readFrom: self base: sourceBase) printStringBase: targetBase

If necessary put it in a private helper method for conversion.

May I ask why you require conversions between the different base systems?
Working on a hex editor for Nautilus? ;)

Bye
T.



Reply via email to