Am 13.08.2010 11:11, schrieb Andrei Pelinescu-Onciul:
The '+' operator is special in the sense that it converts its right operand to the type of the left operand and the result also has the type of the left operand. The other operators force conversion and always have a fixed return type (e..g '*' converts both of its operands to int and always returns int).
More examples:
"1" + 2 = "12" 1 + "2" => error "1" + "2" = "12"
"1" * 2 => error 1 * "2" => error "1" * "2" => error
Why are these errors? You said "The other operators force conversion"
regards klaus
(int)"1" * 2 = 2