Closed vshalvaghasiya closed 6 years ago
public func rounded(toPlaces places: Int) -> Self { guard places >= 0 else { return self } var divisor: Self = 1 for _ in 0..<places { divisor.multiply(by: 10) } return (self * divisor).rounded() / divisor }
public func rounded(toPlaces places: Int) -> Self { guard places >= 0 else { return self } var divisor: Self = 1 for _ in 0..<places { divisor.multiply(by: 10) } return (self * divisor).rounded() / divisor }