<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
Hello everyone,<br>
<div class="moz-forward-container"> <br>
Since there are several scenarios (most of them billing related)
which require floating point operations at script level, we've
decided to put together a new math operations module to handle all
of them.<br>
<br>
The <b>mathops </b>module handles floating point numbers
represented as strings at script level. Its functionalities are
grouped in two categories:<br>
-> rounding operations (trunc, ceil, floor, rounding to
integers, rounding to certain number of<br>
decimal places, rounding to significant figures)<br>
-> an expression evaluator (currently supports binary + - /
* operators and nested parantheses)<br>
<br>
Quick example of using the evaluator:<br>
-----------------------------------<br>
loadmodule "mathops.so"<br>
...<br>
$avp(download_speed) = "8.755";<br>
$avp(chunk_size) = "650.104";<br>
$avp(chunks) = 5;<br>
<br>
if (!math_eval("$avp(chunk_size) / $avp(download_speed) *
$avp(chunks)", "$avp(time)")) {<br>
xlog("ERROR in expression evaluation!\n");<br>
}<br>
<br>
xlog("Download time left: $avp(time) seconds\n");<br>
...<br>
-------------------------------------<br>
<br>
You can control the precision of the results with the <i>decimal_digits</i>
module parameter. For details regarding the rounding operations,
please browse the module documentation [1] posted on the project
website.<br>
<br>
Suggestions and feedback are appreciated as always.<br>
<br>
[1]:
<meta http-equiv="content-type" content="text/html;
charset=ISO-8859-1">
<a
href="http://www.opensips.org/html/docs/modules/devel/mathops.html">http://www.opensips.org/html/docs/modules/devel/mathops.html</a><br>
<br>
Best regards,<br>
<pre class="moz-signature" cols="72">--
Liviu Chircu
OpenSIPS Dev
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a></pre>
</div>
</body>
</html>