Input stream with

Andre-Marcel Hellmund hellmund@fzi.de
Thu Mar 19 21:43:00 GMT 2015


Hi,

I am not sure which of the two lists is the appropriate one, so sorry 
for using both :-)

Given the following simple test program:

#include <cstdint>
#include <iostream>
#include <sstream>

int main () {
   std::stringstream ss;
   ss << "0xFFFFFFFF";
   int32_t val = 0;
   ss >> std::hex >> val;
   std::cout << std::hex << val << std::dec << " - " << ss.fail() << 
std::endl;
   return 0;
}

The output of the program is: 7fffffff - 1

In the first instance, I was somehow expecting the value of 'val' to be 
-1, so I was wondering which part of the C++ standard defines those 
conversion rules and hence explains why my expectation was totally 
wrong. Could someone please give me a hint?

Thank and Best Regards,
Andi



More information about the Libstdc++ mailing list