hex string to int?
Jonathan M Davis
jmdavisProg at gmx.com
Mon Jul 11 12:42:09 PDT 2011
On Monday 11 July 2011 13:24:27 Kai Meyer wrote:
> Is there a built-int ton convert a hex string like "0x0A" to the int "10"?
Look at std.conv. It look like you can get parse to do it if you give it a
radix - e.g. parse!int(str, 16) - though you'll have to strip off the "0x" at
the front. to will do the conversion in the other direction, but it doesn't
seem to have a way to give a radix for converting from string to int, and it
can't handle converting to int based on the "0x" at the front. It sounds like
a good feature request though.
For the moment, however, you can get std.conv.parse to do it.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list