Skip to content

WIP: extended  MATH  command to calculate with and format output to hexadecimal representation

Daniel Franke requested to merge DerDan/cmake:master into master

Extend the command MATH :

  • evaluate the expressions in 64bit
  • evaluate numeric constants in hexadecimal representation (e.g 0x100)
  • check for "divide by 0"
  • improved syntax check
  • optionaly specify output format to be HEXADECIMAL or DECIMAL (default)

For example::

math(EXPR value "100 * 10" ) results in value is set to "1000"

math(EXPR value "100 * 10" DECIMAL) results in value is set to "1000"

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"

math(EXPR value "100 / 0") results in value is set to "ERROR", and a "divide by zeror" is reported

math(EXPR value " Y") results in value is set to "ERROR", and a "syntax error" is reported

Edited by Daniel Franke

Merge request reports