Hi guys,
I am using Asterisk 13.13.1
And in my dialplan I want to convert a float variable to integer. I have previously used the function
Set(rembalance = ${MATH(${bill},int)})
but didnt work. I get the error
func_math.c:258 math: Supply all the parameters - just this once, please
You are seeing that error because you are not supplying a properly formed expression to the function. The function expects an expression in the following format:
value1<operator>value2
So something like 1+2 or 5.8*6. You are missing the second value in your expression. To get it to work you could Just add zero to your number so it won’t change the value. Something like the following:
Set(rembalance=${MATH(${bill}+0,int)})
More info here. However as @johnkiniston pointed out the CEIL, FLOOR, ROUND or TRUNC functions should also do what you need and probably in a more obvious way, so I’d go with one of those instead.
@kharwell @johnkiniston I will try the above advice now. Thanks much
I wrote the FLOOR function like this
same => n,Set(rembalance= FLOOR(${billmin}))
When I did it this way
same => n,Set(rembalance= ${FLOOR(${billmin})})
It says no function FLOOR found
Is it wrong?
Try it as Set(rembalance=$[FLOOR(${billmin}])
1 Like