Use String Functions into a BigDecimal Expression

53 views
Skip to first unread message

stpa...@maggioli.it

unread,
Nov 27, 2009, 12:02:05 PM11/27/09
to Jep Java Users
Hi,


Is there a way to use BigDecimal and String function in the same
expression?

For example with this dummy expression:
if("a"=="b", 10*0.9, 2*0.88)

i have this error:

com.singularsys.jep.functions.IllegalParameterException: ==: lllegal
parameter a(String) expected BigDecimal parameter no 0

My java code is:

Jep jep=new Jep(new BigDecComponents(MathContext.DECIMAL128));
jep.setComponent(new StringFunctionSet());
jep.parse(expression);
ret=jep.evaluate();

Thanks
Stefano

Richard Morris

unread,
Dec 6, 2009, 5:23:43 PM12/6/09
to jep-...@googlegroups.com
Dear Stefano,

Sorry for the delayed reply.

Facilities for using BigDecimals with strings were made available with
Jep 3.3.

The big decimal components has a constructor which allows strings
BigDecComponents(MathContext mc, boolean allowStrings)
if the second argument is true then a limited number of string
operations are possible. Strings can be added with + and compared with
=,> etc. No string functions are loaded by default but you could add
functions which operate on string with jep.addFunction().

Rich
> --
>
> You received this message because you are subscribed to the Google Groups "Jep Java Users" group.
> To post to this group, send email to jep-...@googlegroups.com.
> To unsubscribe from this group, send email to jep-users+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jep-users?hl=en.
>
>
>


--
Richard Morris
Web: www.singsurf.org www.pfaf.org
Email: ri...@singsurf.org
Tel: (+44) 01208 872963
Post: 1 Lerryn View, Lerryn, Lostwithiel, Cornwall, PL22 0QJ

stpa...@maggioli.it

unread,
Dec 7, 2009, 2:56:10 AM12/7/09
to Jep Java Users
Thank's for your reply.

I have a trial version (3.3.0) for evaluate this product but there
isn't a constructor BigDecComponents(MathContext mc, boolean
allowStrings). This constructor there isn't in javadoc documentation.

Thank's.

Bye Stefano
> > For more options, visit this group athttp://groups.google.com/group/jep-users?hl=en.
>
> --
> Richard Morris
> Web:www.singsurf.orgwww.pfaf.org
> Email: r...@singsurf.org
Reply all
Reply to author
Forward
0 new messages