On Mon, 14 Oct 2002, Henri Yandell wrote:

> Has the following been considered:
> 
> <fmt:formatNumber value="424.233" maxFractionDigits="-1"/>
> 
> which outputs 420
> 
> Doesn't seem to work for me [I had wild hopes] and it seems
> surprisingly hard to find a standard way to do this. I can't fathom a
> way to do it using NumberFormat, and there's nothing leaping out in
> java.lang.Math. Both would be a pain anyway as I want it as a
> formatting attribute in JSP.
> 
> Am I missing something obvious?

I believe this kind of generalized mathematical rounding is beyond the
scope of NumberFormat, which engages in rounding only when necessitated by
truncation.  You can do what you need to do with Math.round() (by dividing
and then multiplying), but offhand, I don't think there's any way to do it
with NumberFormat.

-- 
Shawn Bayern
"JSTL in Action"   http://www.jstlbook.com


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to