Undifined behavior or something else?

What will printed to console, VS2008 prints 0. why, is it correct? because i read that:
4.9 Floating-integral conversions An rvalue of a floating point type can be converted to an rvalue of an integer type. The conversion truncates; that is, the fractional part is discarded. The behavior is undefined if the truncated value cannot be represented in the destination type.
1
2
3
4
....
char ch = 256;
std::cout << ch << std::endl;
....



I would image that it will print 0 because:
char value ranges 0 (binary: 00000000) to 255 (binary: 11111111)
hence 256 makes it loop round again to 0
cout probably then prints out the actual value of that.
Topic archived. No new replies allowed.