jeudi 26 février 2015

Divison of int and double



int x=5, y=2 System.out.println(x/y-(double)(x/y);


Why is the answer 0 when i run it on Eclipse. I divide (int)5/2= 2 by property of shaving off the .5 left. Then (double)5/2= 2.5, so 2-2.5= -0.5.




Aucun commentaire:

Enregistrer un commentaire