How To Construct Arithmetic Expressions

How To Construct Arithmetic Expressions

Welcome to our Knowledge Base

Documentation | Blog | Demos | Support

< All Topics
Print

How To Construct Arithmetic Expressions

Writing Expressions

Arithmetic operators and parentheses can be combined to create long, complex expressions. Arithmetic expressions are evaluated based on the standard rules of precedence. Parentheses alter the order of evaluation.

Spaces between operands and operators can be used for clarity, but are not required.

For example, Salary * 1.1 and Salary*1.1 are equivalent.

Data Types

Arithmetic expressions yield a numeric result (if possible).

Operands should preferably be of a numeric data type, but character types are converted into an equivalent number as shown in the following example:

” ” (a space) is 0.

“-2″+5 is 3.

“2”*”-4″ is -8.

If a character value cannot be converted to a number (e.g., “abcd”), an error message is returned and the value is treated as 0.

Decimals and Rounding

The result of an arithmetic expression has as many decimal places as are found in the operand with the most decimal places in the expression. If the result is assigned to a field, variable, or form field that has fewer decimal places than the result, the result takes on the number of decimal places in the field, variable, or form field. Results are rounded as required. Rounding occurs only after the entire expression has been evaluated as shown in the following examples:

5/2 is 3

5/2.0 is 2.5

1+1.01 is 2.01

1.01+(5/2) is 3.51

Was this article helpful?
5 out of 5 stars

1 rating

5 Stars 100%
4 Stars 0%
3 Stars 0%
2 Stars 0%
1 Stars 0%
5
How can we improve this article?
Please submit the reason for your vote so that we can improve the article.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

pt_BRPortuguese