Round up the decimals

How can I make some decimals disappear? “round()” makes them all disappear, quantizing them in limit does exactly what I want, but it still outputs the same huge amount of numbers (text1 op).

If you just want to round up, math.ceil(#) does that. There’s also a math.floor(#).

Hi @Keito07

round would do it

n = 13.586749547
decimals = 3
round(n, decimals)
# returns 13.586

cheers
Markus

Just to add a third voice here - the problem here is that CHOP input to the Text TOP is a floating-point number and Python will convert it to a string with a lot of decimal places by default, even if it’s been through round() or any other function which returns a floating-point value.

There are two ways to format it - you could either do it all in the expression:

"{:.2f}".format(op('limit1')['chan1'].eval()) would give two decimal points.

Alternatively if you turn on CHOP Value %-Replace and set the CHOP parameter, you can use eg %.2f as the text.