Why does (360 / 24) / 60 = 0 ... in Java

Posted by Ankur on Stack Overflow See other posts from Stack Overflow or by Ankur
Published on 2010-03-19T07:37:23Z Indexed on 2010/03/19 7:41 UTC
Read the original article Hit count: 130

Filed under:
|
|

I am trying to compute (360 / 24) / 60 I keep getting the answer 0.0 when I should get 0.25

In words: I want to divide 360 by 24 and then divide the result by 60

public class Divide {

public static void main(String[] args){
  float div = ((360 / 24) / 60);
  System.out.println(div);

}

}

This prints out:

0.0

Why is that? Am I doing something really stupid, or is there a good reason for this

© Stack Overflow or respective owner

Related posts about java

Related posts about float