[asterisk-users] Problem with REMAINDER? 957%60 be 15 remainder 57 not 15 remainder -3 ?
James Thomas
jthomasdpu at gmail.com
Fri Oct 21 10:27:11 CDT 2016
All I can tell you is where -3 comes from.
>From http://www.voip-info.org/wiki/view/Asterisk+Expressions :
REMAINDER(x,y) computes the remainder of dividing x by y. The return value
is x - n*y, where n is the value x/y, rounded to the nearest integer. If
this quotient is 1/2, it is rounded to the nearest even number.
-3 comes from:
n = x/y = 957/60 = 15.95 which rounds to 16
n*y = 16*60 = 960
x - 960 = 957-960 = -3
I'm not mathematically gifted either but I think the n is the problem. it
shouldn't be the rounded result it should be the integer part of x/y (n=15)
Can you just use modulo instead: ${MATH(${myNum}%60,int)}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20161021/1ba0f24e/attachment.html>
More information about the asterisk-users
mailing list