Returns this value rounded to an integral value using “schoolbook rounding.”
- Xcode 9.0+
- Swift Standard Library
The nearest integral value, or, if two integral values are equally close, the integral value with greater magnitude.
rounded() method uses the
.to rounding rule, where a value halfway between two integral values is rounded to the one with greater magnitude. The following example rounds several values using this default rule:
To specify an alternative rule for rounding, use the
rounded(_:) method instead.