[asterisk-users] Problem with REMAINDER? 957%60 be 15 remainder 57 not 15 remainder -3 ?
Jonathan H
lardconcepts at gmail.com
Fri Oct 21 07:33:33 CDT 2016
I'm not mathematically gifted, but shouldn't 957%60 be 15 remainder 57?
Google and my desktop calculator certainly think so.
So where am I going wrong here? The following code
exten => 7,1,Verbose(Context: ${CONTEXT} Exten:${EXTEN})
same => n,Set(myNum=957)
same => n,Set(sec=$[REMAINDER(${myNum},60)])
same => n,Set(sec=$[ABS(${sec})])
same => n,Set(sec=$[${MATH(${sec}+0,i)}])
same => n,Verbose(1,${myNum},${sec})
gives me
-- Executing [7 at fromvoipfone201:1] Verbose("PJSIP/6001-00000007",
"Context: fromvoipfone201 Exten:7") in new stack
Context: fromvoipfone201 Exten:7
-- Executing [7 at fromvoipfone201:2] Set("PJSIP/6001-00000007",
"myNum=957") in new stack
-- Executing [7 at fromvoipfone201:3] Set("PJSIP/6001-00000007",
"sec=-3") in new stack
-- Executing [7 at fromvoipfone201:4] Set("PJSIP/6001-00000007",
"sec=3") in new stack
-- Executing [7 at fromvoipfone201:5] Set("PJSIP/6001-00000007",
"sec=3") in new stack
-- Executing [7 at fromvoipfone201:6] Verbose("PJSIP/6001-00000007",
"1,957,3") in new stack
Where is -3 coming from?!?
I can flip it around by using ABS to stop people freaking out when
they hear a track is "15 minutes minus 3 seconds long", but it's still
incorrect, isn't it?
(I add the second MATH function to everything I do now to make it an
integer as it seems you never can tell with Asterisk, just ignore it!)
Any ideas? Thanks.
More information about the asterisk-users
mailing list