Check out my debugger patch and see if this is happening to you. Running Pd-extended 43.4 on Mac OS 10.6.8. For what ever reason I can't get [expr] to divide non-variables. This is a problem when I am using [expr] to accomplish conditionals (i.e., "if ($f1==$f2, (140/127)*$f3, 0). I keep getting a constant 0 or 1 output. When I isolate the simple expression 140/127, [expr] gives me a 1 or 0 inconsistantly.
expr_test.pd
-
Is non-variable division in [expr] broken?
-
It's because you are performing integer division, in which 3/5=0. Use [expr 3.0/5] instead, that will output 0.6.
I thought everything defaulted to float in PD. Seems that I'm wrong, or the [expr] object is an exception.
-
I didn't know that. There's no warning to be seen nowhere.
@JCPedroza is right. Morover, I've found that you can convert the integer to a float, in this way:
[bang( | [expr float (3)/5] | [0.6]
Between "float" and the bracketed number (3) you need a space.
All expr family objects support a variety of functions as follows:
http://yadegari.org/expr/expr.htmlI live and love in Argentina
-
There has already been a thread about this, 5 months ago, it seems:
http://forum.pdpatchrepo.info/topic/8435/issue-w-the-expr-objectI live and love in Argentina
-
Hi all,
Indeed [expr] is an exception in Pd (see 2.2.1.1.3 Expression on this link: http://www.pd-tutorial.com/english/ch02s02.html)
@LandonPD wrote:
I've found that you can convert the integer to a float, in this way:
Or you can simply use
[expr 3./5.]
Take care,
Gilberto -
Johannes Kreidler is pedagogically awesome. I don't know much about him but it's impossible not to admire his work.
I live and love in Argentina
-
Yeah, he is amazing. I like so much that website of his that I bought two physical copies of it (it's published as a book named Loadbang), one for me and one for my university library. I seriously can't recommend it enough, it's in my opinion the best book for teaching or learning Pd.