[OpenSIPS-Users] Failure when converting floating point to int

Bogdan-Andrei Iancu bogdan at opensips.org
Wed Aug 5 10:02:56 CEST 2015


Hi,

The {s.int} transformation does not support float input. But you can 
convert from string float to string int (in a hackish way) by using the 
{s.select} string transformation, to get the part before the dot. Try:
$(avp(user_balance){s.select,0,.}{s.int})

Regards,

Bogdan-Andrei Iancu
OpenSIPS Founder and Developer
http://www.opensips-solutions.com

On 05.08.2015 02:31, Admin wrote:
> Hi,
>   I am trying to convert a floating point number to int but got empty
> string. The floating point is stored as a string in redis server.
>
> $avp(user_balance) = "23.55";
> xlog("L_INFO", "User balance is $(avp(user_balance){s.int})\n");
>
> The output is:
>
> Aug  4 18:13:25 /usr/local/opensips/sbin/opensips[13031]: User balance
> is
>
> i need to convert the user balance to int.
> What am i doing wrong?
>
> I am running OpenSIPS (2.1.0 (x86_64/linux)).
>
> Thanks.
>
>
>
>
>
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>




More information about the Users mailing list