Hi Liviu,
thanks for pointing to the current state of math_eval. It is definitely much
more user friendly.
Googling “opensips math_eval” gave me only the 1.10 version of math_eval
documentation with only the binary operations at that time.
As usual - one should have looked better.
I was obviously stuck with the assumption that a value should always come first
in an RPN expression.
Greetings,
xaled
From: Users [mailto:[email protected]] On Behalf Of Liviu Chircu
Sent: Montag, 10. Juli 2017 13:06
To: [email protected]
Subject: Re: [OpenSIPS-Users] negative values in math_rpn
I suggest you use math_eval() - it's much more human friendly. The following
should work:
$var(neg) = "-6.135";
$var(neg_int) = $(var(neg){s.int});
math_eval("abs($var(neg_int))", "$var(result)");
OTOH, if you really want to use RPN, this will fix it:
math_rpn("abs $var(neg_int)", "$var(result)");
Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com
On 10.07.2017 13:55, xaled wrote:
Hi,
am I doing something wrong, or can math_rpn not handle negative values?
$var(neg) = "-6.135";
$var(neg_int) = $(var(neg){s.int});
math_rpn("$var(neg_int) abs", "$avp(result)");
2017-07-10T12:47:59.804008+02:00 fra-ivr01 /usr/local/sbin/opensips[10971]:
DBG:mathops:w_evaluate_rpn: Evaluating expression: -6 abs
2017-07-10T12:47:59.804339+02:00 fra-ivr01 /usr/local/sbin/opensips[10971]:
WARNING:mathops:get_rpn_op: Parse expr error: Invalid operator! <-6>
2017-07-10T12:47:59.804669+02:00 fra-ivr01 /usr/local/sbin/opensips[10971]:
ERROR:mathops:evaluate_rpn: Failed to parse RPN!
Thanks,
xaled
_______________________________________________
Users mailing list
[email protected] <mailto:[email protected]>
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
_______________________________________________
Users mailing list
[email protected]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users