Yurttas/PL/SL/python/docs/core-python-programming/doc/20/ref/conversions.html

From ZCubes Wiki
Revision as of 20:08, 7 November 2013 by MassBot1 (talk | contribs) (Created page with "<div class="navigation"> {| width="100%" cellspacing="2" align="center" | yurttas/PL/SL/python/docs/core-python-programming/doc/20/ref/expressions.html|[[Image:yurttas_...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


5.1 Arithmetic conversions

When a description of an arithmetic operator below uses the phrase ``the numeric arguments are converted to a common type,'' the arguments are coerced using the coercion rules listed at the end of chapter 3. If both arguments are standard numeric types, the following coercions are applied:

  • If either argument is a complex number, the other is converted to complex;
  • otherwise, if either argument is a floating point number, the other is converted to floating point;
  • otherwise, if either argument is a long integer, the other is converted to long integer;
  • otherwise, both must be plain integers and no conversion is necessary.

Some additional rules apply for certain operators (e.g., a string left argument to the `%' operator). Extensions can define their own coercions.


See About this document... for information on suggesting changes.