On Mon, 14 Oct 2002, Shawn Bayern wrote:

> > 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.

Does JSTL have to limit itself to NumberFormat?

Basically I have:

static public int roundToNearest(int x, int y) {
    return (int)roundToNearest((double)x, (double)y);
}
static public double roundToNearest(double x, double y) {
    return (double)((Math.round(x/y))*y);
}

which works fine, but obviously I want to use it in JSP as it is
presentation logic and not business logic. Would be nice if JSTL offered
such from its fmt taglib.

Hen


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

Reply via email to