Object that knows which number is odd or even
Dear Reader,
I would like to know, if there is an object, that can route me a the incoming numbers whether they are odd or even?
Thank you,
all the best,
tEd
> I would like to know, if there is an object, that can route me a the incoming numbers whether they are odd or even?
Here's the point where someone mentions that it's a common beginner error to imagine that there's a single object that does anything one wants to do, and that perhaps you might want to think for a moment about what the % object does when its argument is 2.
I'll leave the patching beyond this as an opportunity for your own edification.
There are some things a man does for himself.
yes, this helps a lot...
I like to learn from others:) - this is my way and it works!
all the best
tEd
The other thing worth doing is Googling.
The search string 'odd even site:cycling74.com' returns, among the other wheat and chaff, .
If you *really* want to learn from others, Google the list.
Or, as the Cowboy in Black said to Arthur Putey, "A man's gotta do what a man's gotta do, and there ain't no sense in runnin'. Now, you gotta turn, and you gotta fight, and you gotta hold your head up high. Now you go back in there, son, and be a man. Walk tall."
(For Monty Python cognoscenti)
Right!
I've gotta agree. :)
Even though i use the [if] object regularly, i don't know much about it's ins and outs...is this much worse.
Using [% 2] instead of [& 1] is sort of softcore.
At the machine level, using modulo (%) is going to take 5-10 as much time as using bit-and (&). But this is talking about nanoseconds; compared to the overhead of message passing in Max, we're talking about an impact in the area of 0.1% -- not something to lose sleep over. OTOH, if you have two easy alternatives, why not take the more efficient one?
Having done a fair amount of time-critical close-to-the-machine programming, it's simply a habit to minimize the use of if statements and division/modulo operations. But again, once you're programming at the Max level, this is simply not worth losing sleep over.
In Max programming, the only rule is TMTOWTDI (there's more than one way to do it). The reason I went for the gate construct was that, to my mind, it better visualizes the dataflow. But if you want to use an if object, sure, go ahead...
Indeed.
On Mar 12, 2008, at 4:07 AM, Peter Castine wrote:
> TMTOWTDI (there's more than one way to do it)
barry threw
Media Art and Technology
San Francisco, CA
Work: 857-544-3967
Email: bthrew (at) gmail (dot) com
Web: www.barrythrew.com
Nice patch, Barry.
Just note that it will break for absolute values > 16,777,216.
A patch is not likely to get values that large (or small), but you should be aware of the limitation. It's dem ol' 24-bit floatin' point blues agin, Mama!
Quote: Peter Castine wrote on Wed, 12 March 2008 05:07
----------------------------------------------------
> Using [% 2] instead of [& 1] is sort of softcore.
In terms of efficiency, yes. But it's generally been my
experience that the average and relatively innumerate
person is a lot more familiar with dividing by two than
with logical operators, and the idea was to suggest a
way to visualize the problem rather than just writing the
person a patch and perpetuating the cycle of the sequential
grovel.
Your mileage may vary - but you're absolutely right
about relative microefficiencies.
All I need is 127.
b
On Mar 12, 2008, at 4:29 PM, Peter Castine wrote:
>
> Nice patch, Barry.
>
> Just note that it will break for absolute values > 16,777,216.
>
> A patch is not likely to get values that large (or small), but you
> should be aware of the limitation. It's dem ol' 24-bit floatin'
> point blues agin, Mama!
> --
> ----
> Peter Castine
> Litter Power:
> iCE Tools:
>
barry threw
Media Art and Technology
San Francisco, CA
Work: 857-544-3967
Email: bthrew (at) gmail (dot) com
Web: www.barrythrew.com
Yeah, I've spent too many decades bit-munging.
However, in my teaching experience, most people's eyes glaze over equally fast when talk goes to modulo as it does to bit masking. Every now and again I've got someone who's done Fortean (Babbittean) Set Theory and then modulo makes lots of sense. But that's sorta exceptional. I know I did both modulo arithmetic and binary representation in about 3rd grade, but it seems most people were too busy making spitballs to take notice.-
As for the sequential grovel... I was hoping that my Waynesque (as in John) exhortation would be read as "Ah shown you once, now git out 'n' do it yerself!"