Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (36 sloc) 969 Bytes
layout language permalink command related_commands
api-command
Java
api/java/round/
round
ceil floor
ceil/
floor/

Command syntax

{% apibody %} r.round(number) → number number.round() → number {% endapibody %}

Description

Rounds the given value to the nearest whole integer.

For example, values of 1.0 up to but not including 1.5 will return 1.0, similar to floor; values of 1.5 up to 2.0 will return 2.0, similar to ceil.

Example: Round 12.345 to the nearest integer.

r.round(12.345).run(conn);

// Result:
12.0

The round command can also be chained after an expression.

Example: Round -12.345 to the nearest integer.

r.expr(-12.345).round().run(conn);

// Result:
-12.0

Example: Return Iron Man's weight, rounded to the nearest integer.

r.table("superheroes").get("ironman").g("weight").round().run(conn);
You can’t perform that action at this time.