Operations question | Sololearn: Learn to code for FREE!


Operations question

var a = 19, b = 4 b /= a print(b) Result: 0 Why is this 0? Is it because 4/19 is less than a whole number?

1/4/2020 9:37:50 PM

otto man

1 Answer

New Answer


This is Swift. When both operands are integers, division rounds the result to the nearest integer towards zero. In other words, the result is truncated.