Given double foo
I can assign it from a hex format string using sscanf
like this:
sscanf("0XD", "%lg", &foo)
But I cannot seem to get an istringstream
to behave the same way. All of these just write 0 to foo
:
istringstream("0XD") >> foo
istringstream("0XD") >> hex >> foo
istringstream("D") >> hex >> foo
This is particularly concerning when I read here that the double
istream
extraction operator should:
The check is made whether the
char
obtained from the previous steps is allowed in the input field that would be parsed bystd::scanf
given the conversion specifier
Why can't I read hex from an istream
? I've written some test code here if it would be helpful in testing.