This feels like a stupid question, but I can't find the answer anywhere in the Java documentation. If I declare two ints and then divide them, what exactly is happening? Are they converted to floats/doubles
first, divided, then cast back to an integer
, or is the division "done" as integers?
Also, purely from experimentation, integer division seems to round the answer towards zero (i.e. 3/2 = 1
and -3/2 = -1
). Am I right in believing this?