// convertBuiltins.cc // an experiment #include int main() { bool a = false; bool b = true; short s = 2; int i = 100000; float f = 2.3; double d = 1.23456789e+198; cout << "s = " << s << " and " << "b = " << b << endl; s = s + b; // b is converted to integral value 1, so s becomes 3 cout << "s = " << s << endl; cout << "a = " << a << " and " << "s = " << s << endl; a = s; // s is non-zero, so is converted to 1 (true), so a becomes true cout << "a = " << a << endl; cout << "s = " << s << " and " << "i = " << i << endl; s = i; // implementation dependent, may make s negative cout << "s = " << s << endl; cout << "i = " << i << " and " << "f = " << f << endl; i = f; // truncates f, i becomes 2 cout << "i = " << i << endl; cout << "f = " << f << " and " << "d = " << d << endl; f = d; // d is too large for f...what happens??? Watch! cout << "f = " << f << endl; // By popular demand return 0; }