title: Multiplying by an Integer by a Float/Double in Java
body: <p>I'm trying to do something so simple: multiply an integer by a float/double:</p>
  
  <pre><code>public class A {
      public static void main(String[] args) {
          int x =  (int) 0.5 * 100;       
          System.out.println(x);
      }
  }
  </code></pre>
  
  <p>However, although you'd expect this to return <code>x = 50</code>, instead <code>x = 0</code>! The same thing happens when I use <code>float d = 0.5f</code>. Does anyone know what is going on and why this isn't working?</p>