Instance Method

Returns the remainder of this value divided by the given value using truncating division.

값을 나누어 나온 수 중, 나머지를 따로 나누어 값을 반환합니다.

Declaration

func truncatingRemainder(dividingBy other: Float80) -> Float80

Parameters

other

값을 나눌 때 사용하는 Value입니다.

Return Value

The remainder of this value divided by other using truncating division.

값을 나누어 이 값의 나머지를 다른 값으로 나눈다.

import Foundation

let a = 5.0
let b: Double = a.truncatingRemainder(dividingBy: 1.5)

print(b) // 0.5

let result : Double = 12.truncatingRemainder(dividingBy: 2.5)

print(result) // 2.0

나머지를 구해주는 메서드이다. 알아두면 유용할 듯 하다.