
3 Dec
2010
3 Dec
'10
12:17 a.m.
Hi,
It is possibile to transform a string representing a hexadecimal number in the format "0xnumber" or "number" (without "0x") in an integer with lexical_cast<>?
In my experience, lexical_cast<> cannot transform a string representing a hexadecimal number into an integer. unsigned int x = lexical_cast("0x0badc0de"); // throw bad_lexical_cast Instead of using lexical_cast<>, you should use stringstream to do this kind of transform. For example, see the link below: http://stackoverflow.com/questions/1070497/c-convert-hex-string-to-signed-in... Regards, chenwj -- Wei-Ren Chen (陳韋任) Tel:886-2-2788-3799 #1667 Parallel Processing Lab, Institute of Information Science, Academia Sinica, Taiwan (R.O.C.)