title: Why does Java 8 Nashorn (JavaScript) modulo returns 0.0 (double) instead of 0 (integer)?
body: <p>Consider following code sample:</p>
  
  <pre><code>import javax.script.ScriptEngine;
  import javax.script.ScriptEngineManager;
  
  public class Tester {
  
    public static void main( String[] args ) throws Exception {
        ScriptEngine se = new ScriptEngineManager().getEngineByName( "nashorn" );
  
        Object eval = se.eval( "5%5" );
  
        System.out.println( "eval = " + eval );
        System.out.println( "eval.getClass() = " + eval.getClass() );
    }
  }
  </code></pre>
  
  <p>Why it produces the following output?</p>
  
  <blockquote>
    <p>eval = 0.0<br>
    eval.getClass() = class java.lang.Double</p>
  </blockquote>
  
  <p>The result type is <code>java.lang.Double</code> which is <strong>weird</strong>.   </p>
  
  <p>In case the remainder is different than 0 it correctly returns <code>java.lang.Integer</code>, e.g. <code>5%2</code> returns <code>java.lang.Integer' with value</code>1`.</p>
  
  <p>Only 0 is somehow <em>special</em>.</p>
  
  <p>Trying the same JavaScript expression in Firefox 32.0.2 (FindBugs console) works fine and returns plain 0.</p>
  
  <p>Is there any way to force Nashorn to return Integer type instead of Double?</p>