# round

Rounds values to specified precision.

## Syntax

R = round(x)

R = round(x,n)

R = round(x,n,'type')

## Inputs

`x`- The values to round.
`n`- The number of places to round.
`'type'`- The type of rounding to perform.

## Outputs

- R
- The rounded values.

## Examples

Scalar case:

```
R = round(0.5)
``````
R = 1
```

Matrix case:

```
R = round([0.437, 16.605, 0.570, -8.749, -0.594, -0.621], 2, 'decimal')
``````
R = [Matrix] 1 x 6
0.44000 16.61000 0.57000 -8.75000 -0.59000 -0.62000
```

Binary case: Round two nearly equal values to be equal, retaining maximum precision.

```
a1 = 2048 * (3 * 0.1)
a2 = 2048 * 0.3
delta1 = a1 - a2 % rounding difference
bits = -log2(abs(delta1)) - 1
r1 = round(a1, bits, 'binary')
r2 = round(a2, bits, 'binary')
delta2 = r1 - r2 % no rounding difference
``````
a1 = 614.4
a2 = 614.4
delta1 = 1.13687e-13
bits = 42
r1 = 614.4
r2 = 614.4
delta2 = 0
```

## Comments

When `x` is complex, the rounding is applied to the real and
imaginary components.

It should be understood that results from rounding in base 10 are constrained by binary limitations. A value such as 0.1 (base 10) does not have a finite precision representation in base 2 because it has a repeating bit pattern.

The 'binary' and 'sigbits' options are useful when analyzing values whose differences are too small to be observed in base 10.

Double precision (64 bit) values in IEEE 754 have 53 explicit bits, with the leading bit being an implied 1. The 'sigbits' option treats the implied leading bit as significant.