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.
2 odpowiedzi
+ 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))
+ 1
@Hatsy Rei
Thank you very much. It worked.