Im a bit stuck would be grateful for any ideas. Im trying to evaluate an increasing number as a value of a 16th.
1 = 1
5 = 5
17 = 1
32 = 16
34 = 2
I tried using Pow, but that only does the opposite. Is there a way to use expr on this maybe?
Any help would be much appreciated.
Use modulo (%) 16. But then 32 would be 0, you could change that by using an if object.
Brilliant thankn u so much :)
The C programmer in me can’t help noticing that, instead of using an [if], you can do [int]->[- 1]->[% 16]->[+ 1] (assuming you only use positive integers, i.e., neither zero nor any negatives… the modulo operator is a bit idiosyncratic with negative input, but that’s a different story).
In a compiled language the addition and subtraction are generally cheaper than a conditional. In Max, it probably doesn’t make any difference.
Peter, [int]-> [- 1]-> [%16]-> [+ 1] limits all output to 16 or less, with multiples of 16 resulting in 16. Or maybe I misunderstood you.
I’m also not sure the OP was entirely clear regarding the number 16.. If 5=5, 17=1 and 32=2, then what about 16? Does 16=1, 0 or 16? If 1, then 16=17. If 0, then there is an inconsistency with 32=2. So in terms of simplicity, his criteria kinda forces the hand of if.
I assumed, that the OP wanted 16=16 and then start from 17=1 again. So basically: n%16 but if n%16==0: output = 16. Of course then you would have to take care of n==0 with another if statement.
C74 RSS Feed | © Copyright Cycling '74