Integer

If a data type is an int and the user inputs a decimal like 3.5 what will happen to the .5 part of the number? Will the number be rounded? Or will the .5 be removed?

closed account (48T7M4Gy)
Try it.
http://en.cppreference.com/w/cpp/language/implicit_cast
A prvalue of floating-point type can be converted to prvalue of any integer type. The fractional part is truncated, that is, the fractional part is discarded. If the value can not fit into the destination type, the behavior is undefined (even when the destination type is unsigned, modulo arithmetic does not apply). If the destination type is bool, this is a boolean conversion (see below).
Topic archived. No new replies allowed.