[OpenSIPS-Users] negative values in math_rpn

xaled xaled at web.de
Mon Jul 10 12:24:17 EDT 2017

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.





From: Users [mailto:users-bounces at lists.opensips.org] On Behalf Of Liviu Chircu
Sent: Montag, 10. Juli 2017 13:06
To: users at lists.opensips.org
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

On 10.07.2017 13:55, xaled wrote:



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!




Users mailing list
Users at lists.opensips.org <mailto:Users at lists.opensips.org> 


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20170710/42dbebcf/attachment.html>

More information about the Users mailing list