convert base

Hugo via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Mon Jun 1 17:36:05 PDT 2015


On Tuesday, 2 June 2015 at 00:00:43 UTC, Steven Schveighoffer 
wrote:
> On 6/1/15 7:16 PM, Hugo wrote:
>> Thanks! Is there a way to specify a source base different than 
>> 10?
>
> A "source base"? the source base is always binary :)
>
> If you want to go between base string representation, there is 
> parse for going from string to binary.

What I meant was for example being able to pass from console as 
an argument the number to convert lets say in hexadecimal, octal 
or binary representation.

I will check parse though, thanks.

>> And by the way, this method does not seem to work for bases 
>> higher than
>> 36, how could one achieve for example a conversion to a 
>> base-60?
>
> 35 in base-36 is Z. What is 36 in base-37? At some point you 
> run out of alphabet.

Well.. that depends on what you accept as valid characters, 
doesn't it?
Base-64 is a good example.


More information about the Digitalmars-d-learn mailing list