math.rst 940 B

123456789101112131415161718192021222324252627282930
  1. math
  2. ----
  3. Mathematical expressions.
  4. ::
  5. math(EXPR <output-variable> <math-expression> [OUTPUT_FORMAT <format>])
  6. ``EXPR`` evaluates mathematical expression and returns result in the
  7. output variable. Example mathematical expression is ``5 * (10 + 13)``.
  8. Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``,
  9. ``^``, ``~``, ``<<``, ``>>``, and ``(...)``. They have the same meaning
  10. as they do in C code.
  11. Numeric constants are evaluated in decimal or hexadecimal representation.
  12. The result is formatted according to the option "OUTPUT_FORMAT" ,
  13. where ``<format>`` is one of:
  14. ::
  15. HEXADECIMAL = Result in output variable will be formatted in C code
  16. Hexadecimal notation.
  17. DECIMAL = Result in output variable will be formatted in decimal notation.
  18. For example::
  19. math(EXPR value "100 * 0xA" DECIMAL) results in value is set to "1000"
  20. math(EXPR value "100 * 0xA" HEXADECIMAL) results in value is set to "0x3e8"