The short answer is that integer types work with modular arithmetic with module 1 and discard the remainder.
Since you drop test as an integer, modular arithmetic is used with module 1 (for example, 9.5 mod 1), int test = 5 + 3 * (4 - 1) / 2;
With a 32 or 64 bit float this will give 9.5; however, since you chose test as int , the remainder is discarded, and the value referenced by test is 9.
user1639464
source share