https://formestory.tistory.com/m/21?category=842283 참고!
https://developer.apple.com/documentation/swift/double/2886735-rounded 애플
rounded()
공식문서
func rounded(_ rule: [FloatingPointRoundingRule] -> Double
변환할 숫자가 5.5
, -3.4
라고 하자.
floor()
-> [Swift] rounded(.down)
5.0
, -4.0
ceil()
-> [Swift] rounded(.up)
6.0
, -3.0
round()
-> [Swift] rounded(.toNearestOrAwayFromZero)
rounded()
로 사용할 경우 반올림으로 처리된다. (= "schoolbook rounding")6.0
, -3.0
trunc()
-> [Swift] rounded(.towardZero)
5.0
, -3.0