Anvil | Smiths Smiths | Register Register | Login Login |
Search:
Show links Show tools Show tree | Previous document Next document | njet.org > Anvil > Documentation > Language reference > Expressions > Type conversions

Type conversions

Type conversions may occur in arithmetic operations and type operations.

In arithmetic operations (addition, subtraction, multiplication, division, remainder), conversions occur as follows:

  • Both of the operands must be either an integer, float, string- representing integer or string-representing float. If this requirement is not met, the result of an operation is undefined.
  • If either of the operands yield float, or float as string, the returned value is float.
  • Otherwise, the returned value is int.
  • There is an exception: if both operands yield compatible sequences, then these are concatenated together.

In comparison operations, conversions occur as follows:

  • If one of the operands is float and the other is int or float as string, then a float comparison is done.
  • If one of operands is integer and the other is integer or integer as string, then an integer comparison is done.
  • Otherwise, a comparison follows the semantics of the value yielded by the left operand.

Contributes notes:
Add a note
What's new | Anvil