r.round(number) → number number.round() → number
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, callback); // Result passed to callback 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, callback); // Result passed to callback -12.0
Example: Return Iron Man’s weight, rounded to the nearest integer.
r.table('superheroes').get('ironman')('weight').round().run(conn, callback);
Couldn't find what you were looking for?
© RethinkDB contributors
Licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
https://rethinkdb.com/api/javascript/round/