2H. Conversions

Explicit conversions

(int)(x)

Expression (int)(x) is the result of converting x to type int by throwing away everything after a decimal point. For example (int)(2.9) = 2.

(double)(x)

Expression (double)(x) is the result of converting x to type int. For example (double)(2) = 2.0.

Implicit conversions

Wherever necessary, an integer will be converted to a real number and a real number will be converted to an integer. For example, expression sqrt(2) is allowed. It is treated like sqrt(2.0).