[OpenSIPS-Devel] Precision of db_double2str

Daniel Zanutti daniel.zanutti at gmail.com
Thu Mar 1 16:46:31 EST 2018


Hi

I developed a prepaid/postpaid module to handle our billing scenarios. When
dealing with rates, most of them are < 1.00 and precision is very
important. Looking at this conversion function "db_double2str ", it uses
only 2 decimal places:

ret = snprintf(_s, *_l, "%-10.2f", _v);

This isn't enough for billing, most rates have 4 or even 6 decimal places,
like 0.001230.

To fix this, I changed to 9.6, assuming user balance will never be above
999 millions =)

Questions:
1) Can this lead to some bug on opensips?
2) How about changing opensips to use 9.6 or even 10.6, instead of 10.2?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20180301/b103370b/attachment.html>


More information about the Devel mailing list