Operations question | Sololearn: Learn to code for FREE!

0

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

+3

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.