On Jul 28, 5:10 am, chris idr <[EMAIL PROTECTED]> wrote:
> Hi I have this code sent into rhino.
> event.value = ("%.2f",(p.value*h*i.value/12)/(h-1))
>
> p.value=10, h = 5, i.value=5.
> but this code is not evaluated properly, as I get a value to 7-8 decimal
> places, how do I make rhino round it to %.2f (2 decimal places) as it says?
>
> Or if this would never happen with rhino, what do I have to do to make
> this call go to my own java class 'acro' which is already within rhino
> context?
>
> Many thanks for help
>
> Chris Wade
The expression ("%.2f", expr) is merely a parenthesized comma
expression, where "%.2f" is evaluated for its side effects (none) and
then the result of the expression is the right hand side of the
comma.
To round expr to 2 decimal places, do
Math.round(expr * 100)/100
--N
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino