This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Input stream with


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]