Use operators and number classes

The basic math operators can be used to combine any numbers of either class I or class R. Map expressions similar to the following are legal and perform the expected calculations:

3 * .98242E-5 + 568.35 / 59

Be careful when dealing with expressions that mix integer and real numbers, or that use division. These operations might not be as straightforward as you would expect because of the distinction between floating-point numbers and whole numbers.

When computing number operations, the integration engine first tries to determine the nature (the class) of the result. When operands have the same class, the integration engine chooses that class for the results. This means that adding whole numbers results in a whole number and adding floating-point numbers results in floating point numbers.

This behavior might lead to puzzling results, for example the expression 2/3 is computed as an operation between whole numbers, resulting in the whole number 0. Whereas, in the expression 2.0/3.0, literals are detected as floating-point numbers, leading to the value 0.66666

When operands differ in classes, class R is always chosen for the result. This means, that the expression 2 / 3.0 is evaluated as 0.66666… since 3.0 is recognized of being a class R value.

If you want your expression to behave as you expect, you must carefully choose the way you write number literals: 3.0 does not have the same effect as 3. Keep in mind the importance of the classes of the variables you use.

Related Links