IHow do I write this simple math expression?

mbira's picture

I'm not familiar enough with the formatting used for the math expressions. Please feel free to direct me to some documentation explaining it...

In the mean time, how do I write this:

if b = 127 then a = 1 else a = 0

Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

mbira's picture
Re: IHow do I write this simple math expression?

I'm not getting what I'm expecting.

I'm using this expression: b == 127 ? a == 1 : a == 0

I'm wanting the result output to output the a variable, but I seem to only be getting a "0" output (even when b goes to 127).

.lov.'s picture
Re: IHow do I write this simple math expression?

b == 127 ? a = 1 : a = 0

cradle's picture
Re: IHow do I write this simple math expression?

Math expression: "b == 127 ? 1 : 0"

Javascript "return {'a': b == 127 ? 1 : 0};"

BUT DON'T DO THIS... why? if the input value is a conditional 0/1, you can just return it...

Math "b == 127"

Javascript "return {'a': b == 127};"

mbira's picture
Re: IHow do I write this simple math expression?

I get "Unknown Operator type" with that...

EDIT: I'm replying to first response

cradle's picture
Re: IHow do I write this simple math expression?

"==" is the equality operator, "=" is the assignment operator (which you don't use in maths expressions AFAIK)

so "a == 0" was returning a boolean for whether or not 'a' equals 0.

Stick to the standalone maths patch (you can change the operator).

If you need more power, I'd suggest jump straight to Javascript (I don't like math expressions... but then again I'm a coder, not a mathematician ;)

You might want to look at code other people have made, or any of the Apple samples (Jelly.qtz is very complicated and lots to learn).

mbira's picture
Re: IHow do I write this simple math expression?

I'm coming into this from coding as well (PHP) but I'm still a hack, and I have pretty limited JS experience. What I'm trying to achieve is mostly just conditionals, so it's a good time to start learning the JS I suppose.