0

Remainder Operator problem

The remainder operator (a % b) calculates the number of multiples of b that fit within a, and returns the value that is left over, or the remainder. I want to use remainder operator(a % b) print(9.9 % 4) print(9 % 4.3) resulted output with errors.

9th Sep 2018, 2:17 AM
kp kalia
kp kalia - avatar
2 Respuestas
+ 3
As stated by the error message provided, use truncatingRemainder instead. Swift 3 no longer allows modulus operations on floating-point values. print(9.9.truncatingRemainder(dividingBy : 4))
9th Sep 2018, 2:38 AM
Hatsy Rei
Hatsy Rei - avatar
+ 1
@Hatsy Rei Thank you very much. It worked.
10th Sep 2018, 2:44 AM
kp kalia
kp kalia - avatar