[OpenSIPS-Users] [NEW] Mathops module
Liviu Chircu
liviu at opensips.org
Fri Mar 8 11:46:42 CET 2013
Hello everyone,
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.
The *mathops *module handles floating point numbers represented as
strings at script level. Its functionalities are grouped in two categories:
-> rounding operations (trunc, ceil, floor, rounding to integers,
rounding to certain number of
decimal places, rounding to significant figures)
-> an expression evaluator (currently supports binary + - / *
operators and nested parantheses)
Quick example of using the evaluator:
-----------------------------------
loadmodule "mathops.so"
...
$avp(download_speed) = "8.755";
$avp(chunk_size) = "650.104";
$avp(chunks) = 5;
if (!math_eval("$avp(chunk_size) / $avp(download_speed) * $avp(chunks)",
"$avp(time)")) {
xlog("ERROR in expression evaluation!\n");
}
xlog("Download time left: $avp(time) seconds\n");
...
-------------------------------------
You can control the precision of the results with the /decimal_digits/
module parameter. For details regarding the rounding operations, please
browse the module documentation [1] posted on the project website.
Suggestions and feedback are appreciated as always.
[1]: http://www.opensips.org/html/docs/modules/devel/mathops.html
Best regards,
--
Liviu Chircu
OpenSIPS Dev
http://www.opensips-solutions.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20130308/769ad1af/attachment.htm>
More information about the Users
mailing list