Commits

Kirill Simonov committed 52d80bd

Added a table of numeric functions and operators.

  • Participants
  • Parent commits c5ec176

Comments (0)

Files changed (1)

File doc/reference.rst

 Numeric Functions and Operators
 -------------------------------
 
++----------------------+---------------------------+---------------------------+----------------------+
+| Function             | Description               | Example Input             | Output               |
++======================+===========================+===========================+======================+
+| `integer(x)`         | cast *x* to integer       | ``integer(60)``           | ``60``               |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``integer(17.25)``        | ``17``               |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``integer(223607e-5)``    | ``2``                |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``integer(string('60'))`` | ``60``               |
++----------------------+---------------------------+---------------------------+----------------------+
+| `decimal(x)`         | cast *x* to decimal       | ``decimal(60)``           | ``60.0``             |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``decimal(17.25)``        | ``17.25``            |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``decimal(223607e-5)``    | ``2.23607``          |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | |decimal-from-string-in|  | ``17.25``            |
++----------------------+---------------------------+---------------------------+----------------------+
+| `float(x)`           | cast *x* to float         | ``float(60)``             | ``6e1``              |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``float(17.25)``          | ``1725e-2``          |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | ``float(223607e-5)``      | ``223607e-5``        |
+|                      |                           +---------------------------+----------------------+
+|                      |                           | |float-from-string-in|    | ``223607e-5``        |
++----------------------+---------------------------+---------------------------+----------------------+
+| `-x`                 | negate *x*                | ``-7``                    |                      |
++----------------------+---------------------------+---------------------------+----------------------+
+| `x + y`              | add *x* to *y*            | ``13+7``                  | ``20``               |
++----------------------+---------------------------+---------------------------+----------------------+
+| `x - y`              | subtract *y* from *x*     | ``13-7``                  | ``6``                |
++----------------------+---------------------------+---------------------------+----------------------+
+| `x * y`              | multiply *x* by *y*       | ``13*7``                  | ``91``               |
++----------------------+---------------------------+---------------------------+----------------------+
+| `x / y`              | divide *x* by *y*         | ``13/7``                  | ``1.85714285714286`` |
++----------------------+---------------------------+---------------------------+----------------------+
+| `round(x)`           | round *x* to the nearest  | ``round(17.25)``          | ``17``               |
+|                      | integer                   |                           |                      |
++----------------------+---------------------------+---------------------------+----------------------+
+| `round(x,n)`         | round *x* to *n* decimal  | ``round(17.25,1)``        | ``17.3``             |
+|                      | places                    |                           |                      |
++----------------------+---------------------------+---------------------------+----------------------+
+
+.. |decimal-from-string-in| replace:: ``decimal(string('17.25'))``
+.. |float-from-string-in| replace:: ``float(string('223607e-5'))``
 
 
 String Functions and Operators