FloatingPointRoundingRule.towardZero
Round to the closest allowed value whose magnitude is less than or equal to that of the source.
Declaration
case towardZeroDiscussion
The following example shows the results of rounding numbers using this rule:
(5.2).rounded(.towardZero)
// 5.0
(5.5).rounded(.towardZero)
// 5.0
(-5.2).rounded(.towardZero)
// -5.0
(-5.5).rounded(.towardZero)
// -5.0This rule is equivalent to the C trunc function and implements the roundToIntegralTowardZero operation defined by the IEEE 754 specification.