On Jul 16, 12:05 pm, Stewart <[email protected]> wrote:
> I have a suspicion about this... with your result object, are you able
> to access any other methods/fields?
>
> I think what may be happening here is that BigDecimal is not supported
> by Rhino directly. If I'm correct, Rhino handles only
> java.lang.Integer and java.lang.Double as primitives, and not the
> generic java.lang.Number, of which BigDecimal is a subclass.
That's correct.
>
> One way to solve this is to create your own BigDecimal class which
> extends ScriptableObject/implements Scriptable, and using it as a
> wrapper for java.lang.BigDecimal. There may be a neater way than this
> - I'll leave that for anyone that knows better.
Since he's calling "multiply" directly, perhaps his needs are less
complex. At any rate, this works in Rhino as you'd expect:
js> var SourceAmount = new java.math.BigDecimal("32.2")
js> var Rate = new java.math.BigDecimal("12.1")
js> SourceAmount.multiply(Rate)
389.62
_______________________________________________
dev-tech-js-engine-rhino mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-js-engine-rhino