Discussion of Inner Space
Moderators: Lavish Software Team, Moderators
-
Wassup
- GamingTools Subscriber
- Posts: 6
- Joined: Fri Jul 09, 2004 6:27 am
Post
by Wassup » Mon Oct 29, 2007 8:45 pm
While writing a script I ran into issues with integer division using the \ operator:
Code: Select all
function main()
{
variable int temp=0
variable int result=0
result:Inc[${temp}\100]
echo Result 1: ${result}
temp:Inc[1]
result:Set[0]
result:Inc[${temp}\100]
echo Result 2: ${result}
result:Set[0]
result:Set[${temp}\100]
echo Result 3: ${result}
temp:Inc[1]
result:Set[0]
result:Inc[${temp}\1000]
echo Result 4: ${result}
result:Set[0]
result:Set[${temp}\1000]
echo Result 5: ${result}
}
Result 1: 100
Result 2: 1100
Result 3: 1100
Result 4: 21000
Result 5: 21000
Seems to append the value after the \ to the value being divided into, unless it is a 0.
-
Xeniaz
- GamingTools Subscriber
- Posts: 10
- Joined: Wed Jan 04, 2006 7:43 pm
Post
by Xeniaz » Tue Oct 30, 2007 9:27 am
That's very interesting. I'm also getting the same results. I looked over the logic of your code and it looks correct, so it looks to me as if you've found another awesome feature of Innerspace

. You've passed the insanity test, but it'll be interesting to see what answer Lax has for an answer to this problem.
-
Lax
- Owner
- Posts: 6634
- Joined: Fri Jun 18, 2004 6:08 pm
Post
by Lax » Tue Oct 30, 2007 10:16 am
\ is an escape character, you need to escape it to use it as integer division.
${Math.Calc[0\100]} is processed as 0100, which equals 100.0. ${Math.Calc[0\\100]} is processed as 0\100, which equals 0