http://ideone.com/V9rgSC http://ideone.com/LbogiH
As you can see in the first example after assigning 267 to unsigned char we got 255
In second one — 11
Note, that it was on the same machine and programs were compiled with the same compiler and same parameters. That is why you should never allow undefined behavior in your program. BTW, if compiler will generate code for one of those programs which will steal your credit card number, it will be completely standard compliant: compiler have rights to do that.
#include <iostream>
#include <limits>
int main()
{
longlong v = std::numeric_limits<unsignedint>::max() + 0xf0000001LL ;
unsignedint u ;
int i ;
u = v ; // narrowing; destination type is unsigned, the resulting value is v % 2^n
// where n is the number of bits used to represent unsigned int (0xf0000000)
i = v ; // narrowing; destination type is signed, the value is implementation-defined
// may be (usually is) v % 2^n interpreted as a signed value
std::cout << u << ' ' << i << ' ' << 0xf0000000LL << '\n' ;
double f = v ;
bool b = f ; // floating point to bool conversion, non-zero, true
u = f ; // floating point to integral conversion; value (after discarding fractional part)
// can't be represented in the integral type; undefined behaviour
i = f ; // floating point to integral conversion; value (after discarding fractional part)
// can't be represented in the integral type; undefined behaviour
std::cout << std::boolalpha << b << ' ' << u << ' ' << i << '\n' ;
}