# Token: Math

### By

The MATH tag provides the ability to render and display any evaluation quickly and easily within any portion of the OpenWebStudio engine. The provided math library functionality is extensive, and provides the ability to use not only the Math tag, but to also use Mathematical logic in any provided IIF condition Sometimes, it's necessary to have conditions directly in your list.  MATH can be used in any of the rendering areas or in the query itself.

Tip: If you find yourself doing deep comparisons with many ‘flags’ within your system, try simply combining these into a bit array and using standard bitwise logic operations, provided with the AND:BIT, OR:BIT, XOR:BIT and NOT:BIT operations.

## MATH Syntax

The syntax is fairly straightforward.  Ensure that your mathematical formula is solvable; that is, a value can be determined no matter what the physical operations are. As most people are familiar, the standard mathematical order of operations applies – and standard parenthetic logic is provided. The following order of operations is utilized by the OpenWebStudio engine (review the Math library symbols and functions provided further in this section):

FIRST: ( )

SECOND: * ^ % / \

THIRD: + -

FOURTH: AND OR XOR AND:BIT OR:BIT XOR:BIT

MATH Syntax:
{MATH,”Equation”}

### Example

```<span>The resulting value is: {MATH," ABS((7 % 14)/Sin(0.05) + pi() / 12)"}
</span>          ```

Result:

`The resulting value is: 140.320149739507 `

### BITWISE Example

```<span>The resulting value is: {MATH,"NOT:BIT 1000 AND:BIT 1011"}
</span>          ```

Result:

`The resulting value is: 0011`

### Condition Example

```<span>The resulting value is: {MATH,"12+17=29 AND 1+4=6-2"}
</span>          ```

Result:

`The resulting value is: False`

### Condition Example (Strings)

```<span>The resulting value is: {MATH,"12+17=29 AND te=test-st"}
</span>          ```

Result:

`The resulting value is: True`

Note: You can use any, if not all of the mathematical operations within the same question, without fail. For instance:

Sin(35/100) + 12/18 % 4 <= ABS(16*(3-6)) AND SQRT(55123) = 55123^0.5

## Symbols and Functions

OpenWebStudio supports an extensive array of mathematical functions, symbols and logical operators in order to fulfill nearly any requirement. Review the list of definitions below to get a full grasp of the functionality provided within the OpenWebStudio Mathematical Library.

Symbols

 ( ) Parenthesis – The appropriate grouping and enforcement of “out of order” operations requires the need for the use of parenthesis. Group your mathematical statements within parenthesis to force their evaluation before other items contained outside of the grouped equation.Example: (5 + 6) / 11 * Multiplication – Standard multiplication is handled within OpenWebStudio by using the asterisk symbol. Since the asterisk is a standard symbol, it can occur with or without spaces.Example: 5 * 6 ^ Exponents – Raising a value to the power of another, is easily handled by the familiar Exponent symbol. Example: 5 ^ 6 % Modulus – When you would like the identify the remainder of a division of two numbers, the Modulus (mod) operator is available .Example: 15 % 4 \ / Division – To determine the number of time one value is contained within another, division is used. Example: 5 /6 + Addition – The simplest of operations, use the plus symbol, with our without spacing, to add one value to another. Example: 5 + 6 - Subtraction – To subtract one value from another, simply use the standard dash operator. Example: 5 - 6 < Less Than – When used in comparison logic, the result of this equation, when the left hand value is less than the right hand value, the result will be True, otherwise, the result will be False. Example: 5 < 6 > Greater Than – When used in comparison logic, the result of this equation, when the left hand value is greater than the right hand value, the result will be True, otherwise, the result will be False. Example: 5 > 6 = Equal – When used in comparison logic, the result of this equation, when the left hand value is equal to the right hand value, the result will be True, otherwise, the result will be False. Example: 5 = 6 <= Less or Equal – When used in comparison logic, the result of this equation, when the left hand value is less than or equal to the right hand value, the result will be True, otherwise, the result will be False. Example: 5 <= 6 >= Greater or Equal – When used in comparison logic, the result of this equation, when the left hand value is greater than or equal to the right hand value, the result will be True, otherwise, the result will be False. Example: 5 >= 6 <> != Unequal – When used in comparison logic, the result of this equation, when the left hand does not equate to the right hand value, the result will be True, otherwise, the result will be False. Example: 5 <> 6

## Logic Operators

 AND When you would like to combine multiple Boolean based comparisons into one physical statement, in which both requirements are necessary to result in a True Value, use the AND operator. When used against numeric values, the end operator acts as a bit comparison. Example: 5+1=6 AND 7 >= 6 OR When you would like to combine multiple Boolean based comparisons into one physical statement, in which either of the requirements is  necessary to result in a True Value, use the OR operator. When used against numeric values, the end operator acts as a bit comparison. Example: 5+1=6 OR 7 >= 6 XOR When you would like to combine multiple Boolean based comparisons into one physical statement, in which only one of the requirements but never both is necessary to result in a True Value, use the AND operator. When used against numeric values, the end operator acts as a bit comparison. Example: 5+1=6 XOR 7 >= 6 NOT When you would like to return the opposite of a Boolean variable, the NOT operator should be use Example: 5+1=6 AND NOT 7 >= 6 AND:BIT To perform a bitwise comparison of two values in which you want all the bits to result in 1 whenever both the left and right hand bits are one, is the AND:BIT operator. Numbers and text values will automatically cast directly to bit arrays before handling. The end result will be a bit array. Example: 01101011 AND:BIT 11100010 = 01100010 OR:BIT o perform a bitwise comparison of two values in which you want all the bits to result in 1 whenever either the left or  right hand bits are one, is the OR:BIT operator. Numbers and text values will automatically cast directly to bit arrays before handling. The end result will be a bit array. Example: 01101011 OR:BIT 11100010 = 11101011 XOR:BIT To perform a bitwise comparison of two values in which you want all the bits to result in 1 whenever either the left or right hand bits are one but never both, is the XOR:BIT operator. Numbers and text values will automatically cast directly to bit arrays before handling. The end result will be a bit array. Example: 01101011 AND:BIT 11100010 = 00001000 NOT:BIT To perform a bitwise inversion of your variable by toggling all contained Boolean values, the NOT:BIT operator should be used. Numbers and text values will automatically cast directly to bit arrays before handling. The end result will be a bit array. Example: NOT:BIT 11100010 =00011101

## Functions

 ABS Returns the absolute value of a number, meaning casting aside its defined sign and producing the same value, but always positive.Example: ABS(-4) ACOS Returns the angle whose cosine is the specified number. Example: ACOS(0.35) ASIN Returns the angle whose sine is the specified number. Example: ASIN(0.35) ATAN Returns the angle whose tangent is the specified number. Example: ATAN(0.35) CEIL Returns the largest integer greater than or equal to the specified double-precision floating-point number. Example: CEIL(1.1) COS Returns the cosine of the specified angle. Example: COS(0.35) COSH Returns the hyperbolic cosine of the specified angle. Example: COSH(0.35) EXP Returns e raised to the specified value. Example: EXP(27) FLOOR Returns the largest integer less than or equal to the specified double-precision floating-point number. Example: FLOOR(1.1) LN Returns natural log of the specified value Example: LN(27) LOG Returns the log (base 10) of the specified value Example: LOG(27) PI Returns the value of PI Example: PI() ROUND Returns the value closest to the nearest integer from the provided value. Example: ROUND(1.1) SIGN Returns a value indicating the sign of a number. Example: SIGN(1.1) SIN Returns the sine of the specified angle. Example: SIN(0.35) SINH Returns the hyperbolic sign of the specified angle. Example: SINH(0.35) SQRT Returns the square root of the specified value. Example: SQRT(27) TAN Returns the tangent of the specified angle. Example: TAN(0.35)
Average ( Ratings): New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share 