Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Operator (computer programming)
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Operand coercion == {{further|Type conversion}} Some languages implicitly convert (aka [[Type conversion#Implicit type conversion|coerce]]) operands to be compatible with each other. For example, [[Perl]] coercion rules cause <code>12 + "3.14"</code> to evaluate to <code>15.14</code>. The string literal <code>"3.14"</code> is converted to the numeric value 3.14 before addition is applied. Further, <code>3.14</code> is treated as floating point so the result is floating point even though <code>12</code> is an integer literal. [[JavaScript]] follows different rules so that the same expression evaluates to <code>"123.14"</code> since <code>12</code> is converted to a string which is then concatenated with the second operand. In general, a programmer must be aware of the specific rules regarding operand coercion in order to avoid unexpected and incorrect behavior.
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)