Right (sort of). Here's what the spec has to say about division: Binary operator - A {/} B If A and B are null, - return 0 Coerce both A and B to Double and apply operator If operator results in exception, error
In addition, here's some info from java.text.DecimalFormat: DecimalFormat uses half-even rounding (see ROUND_HALF_EVEN) for formatting. So, as Matsuhashi suggests, here are a couple of things you could try with <fmt:formatNumber>: <%@ page contentType="text/plain" %> <%@ taglib prefix="c" uri="http://java.sun.com/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %> <c:set var="var1" value="..."/> <c:set var="var2" value="..."/> <c:set var="var3" value="${var1 / var2}"/> <c:out value="${var3}"/> <fmt:formatNumber value="${var3}" pattern="#"/> <fmt:formatNumber value="${var3}" maxFractionDigits="0"/> If var1=12 and var2=5, you'll get: 2.4 2 2 However, if var1=21 and var2=6, you'll get: 3.5 4 4 Which may not be what you want if you really want integer division (truncation)... Quoting [EMAIL PROTECTED]: > > >i declare 2 variables,then i want to do some > >calculate.the result is 2.4 here,but my desire result > >is 2. > > How about using JSTL's standard <fmt:formatNumber> tag? > > > MATSUHASHI -- Kris Schneider <mailto:[EMAIL PROTECTED]> D.O.Tech <http://www.dotech.com/> --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]