Question
· Aug 17, 2016

Rules for arithmetic operators in Caché

write "5apples" + "7 orange" //Ans :12

 

Values are string , why  add numeric value . its an error or correct . please tell me.

Discussion (7)0
Log in or sign up to continue

Numeric operators convert their arguments to numbers (according to well defined rules) before performing the operation. That's why "5apples"+ "7 orange" gives 12.
Conversely, string operators convert their arguments to strings before the operations is performed.

In other words, regardless of the arguments, the operator automatically performs the necessary conversions according to what it expects.