Weird Program Behaviour
rfletcher
Junior Member
Is there some actual difference between these two chunks of code or is this just some weird behavior from the compilier?
When the string "'GrpmD01*-00180',$0D,$0A" is fed into the two blocks below it produces different results. Version 2 produces the expected result of -18, while version 1 produces a result of -26000something.
Version 1:
Version 2:
When the string "'GrpmD01*-00180',$0D,$0A" is fed into the two blocks below it produces different results. Version 2 produces the expected result of -18, while version 1 produces a result of -26000something.
Version 1:
active(find_string(sTemp,'GrpmD01',1)): //volume changes
{
stack_var char t1[50]
t1 = sTemp
remove_string(t1,'*',1)
nLevels = atoi(t1)/10
}
Version 2:
active(find_string(sTemp,'GrpmD01',1)): //volume changes
{
stack_var char t1[50]
stack_var sinteger t2
t1 = sTemp
remove_string(t1,'*',1)
t2 = atoi(t1)
nLevels = t2/10
}
Comments
-
No solution, only anecdotal corroboration. I have definitely run into this as well.
-
It looks like a signedness casting bug, possibly only when dividing by a number which ends in a 0 in base 10 (from what I observed).
One reliable workaround:nLevels = -atoi(t1)/-10;
Another is to split the operation over two lines, as you found. You can also do:nLevels = atoi(t1)/2; nLevels = nLevels/5;
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums