Convert hex to binary

Jesse Phillips via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Apr 24 11:45:54 PDT 2015


On Friday, 24 April 2015 at 18:14:07 UTC, nrgyzer wrote:
> Hi,
>
> I'm looking for a function that converts my hex-string to a 
> binary representation. In Python I write the following:
>
> myHex = "123456789ABCDEF"
> myBin = myHex.decode('hex')
>
> But how to do the same in D? Is there any function?
>
> Thanks for suggestions!

     import std.stdio;
     void main(){
         import std.conv;
         import std.format;

         auto i = to!ulong("123456789ABCDEF", 16);

         writeln(format("%b", i));
     }


More information about the Digitalmars-d-learn mailing list