Limiting numbers to maximum values?
How do you usually limit integers to a certain maximum? For example everything in an incoming stream which is above 120 should give 120. No intelligence needed, just set it to the allowed maximum if it is higher.
[scale] cannot do it, it delivers numbers outside of its given output range. The number box does it and I could use the [if ...] object but I think there is a more common way.
[clip 0 120] ?
[clip] is good, [split] can sort of do it, [zmap] can do it, but is overkill.
Ah, thanks.
[zmap] is actually good in this case. I [scale] already but it lets the data shoot over the range. With [zmap] this doesn't even occur and I don't need to [clip].
Another (possibly even simpler) approach is to set the "maximum" attribute of a number box - possibly even the one you're using in your UI.
He alludes to that by saying "The number box does it..."
I assumed he was looking for another method, possibly to reduce cpu cycles from the changing graphics.
Yes Chris, this is correct.
The application is going to have many objects and I spare computer energy wherever I can – which takes some energy from me. Mister Newton was right ;-)
zmap?? split?? :D
there is a [maximum 120] object for this task, or for that matter, [expr max($f1,120.)]
As always, when talking about efficiency, measurements are good. Somewhat surprisingly, zmap wins here.
In my experience, [expr] is often the worst candidate, at least as far as efficiency is concerned, but in this case, it's in the running. (Some people may find [expr] more readable for complex operations than a bunch of Max code, though.)
... but how can you do maximum with zmap or with split? both cut off values outside the range.
If I'm understanding you, zmap does the right thing. [split] would need a little trickery with the right outlet which would negate any advantage to using it in this case.
well i thought his question made quite clear that he was looking for maximum or clip, but i could be wrong.
if you want to clip to max 120, you must use [minimum 120], not [maximum] ...
also true.