Maybe an easy one, but I can seem to be able to find a way to round a decimal number to the nearest specified decimal amount.

For example, I want to round this data list to the nearest 0.125 (1/8"). Any thoughts?

Maybe an easy one, but I can seem to be able to find a way to round a decimal number to the nearest specified decimal amount.

For example, I want to round this data list to the nearest 0.125 (1/8"). Any thoughts?

All good solutions, thanks to all.

Round(x, y) works too!

X is the numbers you want to round and y is the decimal places, you can plug in a slider and change it or directly type 8

Round(x, 8).

Thatâ€™s something different than the original question.

Oh you are right!

In that case you can use this expression as David suggested:

f*Cint(v/f)

f=rounding factor, v=values

You could use the example here that pops that expression into a little userobject/cluster:

Just also added a â€śRound To Decimal Placeâ€ť component in the new Pufferfish V2.2

2 Likes

Is there a way to no suppress trailing 0â€™s so the specified decimal places (say 3 deep) are preserved? Iâ€™m seeing numbers that do round to a whole number clip so Iâ€™m getting **7** instead of **7.000** - thoughts on how to adjust this formatting?

*update* : found this thread that addresses my needs -

essentially using an Expression component with `Format("{0:0.000}",x)`

will get you to round off to 3 decimal places and not suppress 0â€™s. Cheers!

There is also settings in GH for how many decimals you see in File>Preferences>Formatting