+ 2

Division in Java

Why when I tried to get the result of 5 / 2 I have 2 in output and not 2.5 ? https://code.sololearn.com/cXP63eq3zOMs/?ref=app

29th Aug 2018, 9:19 PM
Hugo Chan
Hugo Chan - avatar
3 Respostas
+ 5
you can use : 🤗🙆‍♂️ 💗 5.0 / 2 5/ 2.0 5.0 / 2.0
29th Aug 2018, 10:58 PM
NimWing Yuan
NimWing Yuan - avatar
+ 3
Program is treating 5 and 2 as a int value and make a round to down. If you write this as a 5.0 and 2.0 will be 2.5 like double does :)
29th Aug 2018, 10:00 PM
Przemek Drozd
Przemek Drozd - avatar
+ 1
Ok thanks dude
29th Aug 2018, 10:04 PM
Hugo Chan
Hugo Chan - avatar