digitalmars.D.learn - hex string to int?
- Kai Meyer (1/1) Jul 11 2011 Is there a built-int ton convert a hex string like "0x0A" to the int "10...
- Jonathan M Davis (9/10) Jul 11 2011 Look at std.conv. It look like you can get parse to do it if you give it...
Is there a built-int ton convert a hex string like "0x0A" to the int "10"?
Jul 11 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
Jul 11 2011