Round

Not available in this language yet.
Round( value, [ precision ]  )
Round( value, [ precision ]  )
Round( value, [ precision ]  )
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Round( value, [ precision ]  )

Description

The Round function returns a number which is the nearest mathematic value of the operand to the specified precision as a double value.

Parameters

Argument Type Definition and Requirements

value

Number

A number to be rounded with a specific precision.

precision

Number

Optional - Defines how many digits to the right or left of the decimal place should be returned. The default precision is 2 which returns up to the hundredths decimal places. A positive precision specifies digits to the right of the decimal point. A negative precision specifies digits to the left of the decimal point. A zero precision rounds the fractional part of the number.

Returns

A number with its precision modified.

Examples

The query below executes an array of independent rounding operations and returns the results in an array. The result array position matches the position of the execution array position. The first operation takes the value 1234.5678 and by default rounds the value to 2 digits to the right of the decimal point. The result is 1234.57 which is in the top position of the result array. The second operation rounds the value 1234 to a precision of -2. This is two digits to the left of the decimal point, the hundreds position. The operations to the left of the decimal point are zero filled less than the specified precision. The result of 1200 is placed in the third position of the result array.

System.out.println(
        client.query( Arr(
                Round(Value(1234.5678)),
                Round(Value(1234), Value(-2)),
                Round(Value(1234.5678), Value(2)),
                Round(Value(1234.5678), Value(-2)),
                Round(Value(5678.1234), Value(3)),
                Round(Value(1234), Value(-3)),
                Round(Value(5678.1234), Value(-3))
        )).get());
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
Not available in this language yet.
[
   1234.57,
   1200,
   1234.57,
   1200.0,
   5678.123,
   1000,
   6000.0
]

Was this article helpful?

We're sorry to hear that.
Tell us how we can improve! documentation@fauna.com

Thank you for your feedback!