Search code examples
javadivisioninteger-division

Why is (13 / 3 == 4) true?


((13 / 3 == 4) == true) 

why is this equals true? 13/3 = 4.3333 and 4.333 is not equaled 4. Is it about auto cast into an integer? and round?

I tested it in Java EE 8.


Solution

  • Because when you write 13 / 3 you have divided two integer, so the result is only int part, so 4.

    In this way you have the next condition 4 == 4 is true