summaryrefslogtreecommitdiffstats
path: root/Help/command
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-07-05 14:25:56 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-07-05 14:26:05 (GMT)
commitca733cdf4532a4a3d05b82c49a5f2fbf994149de (patch)
treea4da4e97e6094b142b75e5575a4eb7d298422b5f /Help/command
parent5fec622ece869b30560b797e469c93c57d7016b6 (diff)
parent5dbee9d2d0f68e1fc343d04ac00a4a35d43df6fa (diff)
downloadCMake-ca733cdf4532a4a3d05b82c49a5f2fbf994149de.zip
CMake-ca733cdf4532a4a3d05b82c49a5f2fbf994149de.tar.gz
CMake-ca733cdf4532a4a3d05b82c49a5f2fbf994149de.tar.bz2
Merge topic 'math-hex'
5dbee9d2d0 math: Add options to calculate and format output as hexadecimal 8661e7052c math: Diagnose divide-by-zero 7c4c13ffef math: Reject unexpected expression input explicitly 5b0f73a15a math: Use 64-bit integer type for computation 963b8d9f6c math: Add RunCMake.math test to prepare for error cases Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !2056
Diffstat (limited to 'Help/command')
-rw-r--r--Help/command/math.rst18
1 files changed, 17 insertions, 1 deletions
diff --git a/Help/command/math.rst b/Help/command/math.rst
index f99dc3d..63af931 100644
--- a/Help/command/math.rst
+++ b/Help/command/math.rst
@@ -5,10 +5,26 @@ Mathematical expressions.
::
- math(EXPR <output-variable> <math-expression>)
+ math(EXPR <output-variable> <math-expression> [OUTPUT_FORMAT <format>])
``EXPR`` evaluates mathematical expression and returns result in the
output variable. Example mathematical expression is ``5 * (10 + 13)``.
Supported operators are ``+``, ``-``, ``*``, ``/``, ``%``, ``|``, ``&``,
``^``, ``~``, ``<<``, ``>>``, and ``(...)``. They have the same meaning
as they do in C code.
+
+Numeric constants are evaluated in decimal or hexadecimal representation.
+
+The result is formatted according to the option "OUTPUT_FORMAT" ,
+where ``<format>`` is one of:
+::
+
+ HEXADECIMAL = Result in output variable will be formatted in C code
+ Hexadecimal notation.
+ DECIMAL = Result in output variable will be formatted in decimal notation.
+
+
+For example::
+
+ math(EXPR value "100 * 0xA" DECIMAL) results in value is set to "1000"
+ math(EXPR value "100 * 0xA" HEXADECIMAL) results in value is set to "0x3e8"