Page 1 of 1

Math variables

Posted: 20 Mar 2015 05:37
by MURTUMA
I have an initial value 0. Then everytime a flow triggers, it add 1 to value: value = value + 1

Then I test the value in expression: value == 2 * n
True path should execute everytime the value is 0, 2, 4, 6, 8, etc...

Ideally I need an universal solution for n, so that the same solution could be used for example in x^n, x+n, x/n, and so on.

Math is one thing where my english is not good, so I can't really explain my question well. Try to bear with me...

Re: Math variables

Posted: 20 Mar 2015 06:57
by lchiocca
Hi Murtuma,

I don't think you'll be able to get a generic solution for all the problems you listed. I'm also not quite sure I understood the problem, so I'll try to list a couple of tips:

> True path should execute everytime the value is 0, 2, 4, 6, 8, etc...
This one is simple: use the modulo operator. Modulo is the remainder of a division. So for example 6 modulo 2 is 0 (6 divided by 2 is 3 with 0 remainder) while 7 modulo 2 is 1 (7 divided by 2 is 3 with 1 remaining). So you could write an expression "value % 2 == 0" to get what you wanted. Or use "value % 3 == 0" for "0, 3, 6, 9, ...".

> Ideally I need an universal solution for n, so that the same solution could be used for example in x^n, x+n, x/n, and so on.
I don't know what your "x" is supposed to be, so I can't really relate to the problem.

Cheers
Loris

Re: Math variables

Posted: 20 Mar 2015 10:30
by MURTUMA
lchiocca wrote:> Ideally I need an universal solution for n, so that the same solution could be used for example in x^n, x+n, x/n, and so on.
I don't know what your "x" is supposed to be, so I can't really relate to the problem.
Yeah, those examples didn't really support my explanation well.

I'll try again.

Expression: value == 2 * n
n is indefinited variable, so every time value is multiplied by *any number*, expression would return TRUE.

As it seems, there's not such function(indefinite variable), could you add this function to AM scripting language?

Re: Math variables

Posted: 20 Mar 2015 14:41
by lchiocca
Isn't the modulo what you are looking for? (see my first post)

Re: Math variables

Posted: 22 Mar 2015 22:48
by Bushmills
How about value = 2*0. ... 0 is also an "any number", and in your example, no matter what 2 is multiplied with, it will always be multiplied by a number.

Or is it merely determining whether the result of your multiplication is even or odd you're after?

This doesn't quite match the description in your initial post, where you multiply n by two, then test whether the result is a multiple of two - answer to that is simple: that will always be the case.

Maybe you can try to explain in which circumstances you want the result NOT to be true?