Reputation: 55
I have a hexadecimal string like "0xff"
, and want to convert it to int, which is 255.
But Int.fromString "0xff"
gives the answer 0
.
I though that Int.scan
would help. But I'm new to SML.
Upvotes: 1
Views: 481
Reputation: 122489
You can do
StringCvt.scanString (Int.scan StringCvt.HEX) "0xff"
or
StringCvt.scanString (Int.scan StringCvt.HEX) "ff"
Upvotes: 3