# Swift - rint() Function

The Swift rint() function returns an integral value by rounding up the specified number. If x falls exactly at the midway between two integers, the even integer is returned.

### Syntax

In Foundation framework, it is defined as follows:

```public func rint(_ x: CGFloat) -> CGFloat
public func rint(_ x: Float) -> Float
public func rint(_ x: Float80) -> Float80
public func rint(_ __x: Double) -> Double
```

### Parameters

 `x` Specify a value to round.

### Return Value

Returns an integral value by rounding up the x. If x falls exactly at the midway between two integers, the even integer is returned.

### Example:

In the example below, rint() function is used to round the given number.

```import Foundation

print("rint(10.4) = \(rint(10.4))")
print("rint(10.6) = \(rint(10.6))")
print("rint(10.5) = \(rint(10.5))")
print("rint(11.5) = \(rint(11.5))")
print("rint(12.5) = \(rint(12.5))")
```

The output of the above code will be:

```rint(10.4) = 10.0
rint(10.6) = 11.0
rint(10.5) = 10.0
rint(11.5) = 12.0
rint(12.5) = 12.0
```

❮ Swift Math Functions

5