Why does int exp1 = 14/20*100; equals '0' in java?

后端 未结 4 1547
不知归路
不知归路 2020-12-12 07:07

I\'m trying to do some basic math and it keeps popping up as 0. I\'m sure it has to do with it being an int but I don\'t know how to work around it

4条回答
  •  旧时难觅i
    2020-12-12 07:38

    You can change it to 14*100/20 - and then it will give what you want.

    I.e. change the sequence of operations (14/20 is 0)

提交回复
热议问题