Round
Round
Round[ a ] rounds a value to the nearest integer.
Usages
Round[ a ]
Round[ a ] rounds the value of a to the nearest integer. Halves are rounded away from zero. a can be any expression with a numerical value.
| Example | in | out |
|---|---|---|
| A decimal number. | Round[ 3.14 ] |
3 |
| A half is rounded up. | Round[ 2.5 ] |
3 |
| A negative half is rounded down. | Round[ -2.5 ] |
-3 |
| A fraction. | Round[ 7/2 ] |
4 |
| An expression with a numerical value. | Round[ Pi ] |
3 |
Round[ a1, a2, ... ] and Round[ list ]
With more than one value, or a list, each value is rounded and the result is a list.
| Example | in | out |
|---|---|---|
| Three values. | Round[ 1.5, 3.2, 7.4 ] |
{2, 3, 7} |
| A list. | Round[ {1.4, 1.6} ] |
{1, 2} |
Details
- No numerical value: a value without a numerical value is returned unchanged:
Round[ x ]givesx. - To round to a number of decimals, use
Numerical[ a, n ].
Warning
The second argument is not a number of decimals. Round[ 3.14159, 2 ] rounds both values and returns {3, 2}. Use Numerical[ 3.14159, 2 ] to get 3.14.