Round

Revision as of 08:43, 23 December 2009 by Lchrisman (talk | contribs)


Round(x, digits)

Round(x) rounds «x» to the nearest integer.

To round to a given number of digits, i.e,. to the nearest power of 10-digits, use:

Round(X,digits)

Note: The «digits» parameter requires Analytica 4.1 or later.

Library

Math

Examples

Round(1.4) → 1
Round(1.5) → 2
Round(-1.5) → 2
Round(Pi,3) → 3.14200
Round(12345.6,-2) → 12300.0

Number Format

The Round function (along with Floor and Ceil) rounds to the indicated number of digits. However, this does not determine how many digits are shown when the number is displayed. The latter is controlled by the number format settings (CTRL+B). While Round(pi,6) returns 3.141593, this will display as 3.142 if your number format is set to suffix with 4 digits, for example. To see the full result, you can increase the digits in the number format to the maximum (around 16).

Notes about Precision

When «digits» ≤ 6 Analytica 4.2 and higher will return an exact representation of the rounded number. To do this, internally it utilizes a fixed-point real number format. When rounding to more than 6 digits, the result may not always be an exact power of 10.

In Analytica 4.1, or in Analytica 4.2 when «digits» > 6, Round(X,digits) cannot guarantee that the result can be represented exactly as a power of 10. Analytica represents numbers using a binary floating point format. Fractions that are an exact power of 10-1 cannot always be represented exactly in binary -- i.e., they are usually not an exact power of 1/2. Therefore, non-zeros may be observed around the 16th significant digit. The number returned is a number that is as close to the rounded value as can be represented in an IEEE floating-point binary format. Rounded values generally will display as expected in result tables unless you have the number format set to show more than 15 significant digits.


See Also



You are not allowed to post comments.

Comments
<comments />