Divide (Integer) - X by Y

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
blackwinter
GamingTools Subscriber
Posts: 74
Joined: Sun Jun 25, 2006 8:29 am

Divide (Integer) - X by Y

Post by blackwinter » Sun Feb 19, 2012 6:45 am

10.00000\2=10.00200???

echo ${Math.Calc[(10.00\1)]}
echo ${Math.Calc[(10.00\2)]}

is not supposed to be!

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Sun Feb 19, 2012 8:24 am

No the issue you are running into is that \ is the escape character. It's not doing a calculation because you're escaping the 1 and the 2 instead of actually dividing. Your two echoes resolve to:

Code: Select all

echo ${Math.Calc[(10.001)]}
echo ${Math.Calc[(10.002)]}
Thus the working-as-intended responses.

To use the integer divide operator, which is also the escape character, use a second \ (escape the divide operator).

Correct syntax:

Code: Select all

echo ${Math.Calc[(10.00\\1)]}
echo ${Math.Calc[(10.00\\2)]}

Post Reply