Jump to content

Reaktor/Tutorials/Rounding a number

From Wikibooks, open books for an open world
Reaktor Main Page | Tutorials | Modules | Synthesis

Suppose you have a floating point number, for example the output of a mouse area, and you want to round this number to the lower integer bound. One way to do this is to Modulo/Divide the number by 1.

 Input -> Modulo.A   Modulo.Div -> RoundedNumber
 1     -> Modulo.B

It is often useful to add a StepFilter on the output if you only want to trigger on changing values.

In Core, you can round a number by building a macro with a float input and an integer output. If you want to round to the upper number, you can add 1 first. If you want to round to the upper number for fractional values bigger than 0.5, add 0.5 first.