Round off to two decimals

Hello all,

For a project I wrote a Python script in Grasshopper that adds rectangles. I made the area shows automatically in the Rhino view port.

I want round off to two decimals but the round component only gives whole numbers.
What component do I have to use or do I have to fix it in another way.

Thanks!

Kind regards,

Jan Sietse

You can use Pufferfish Round to decimal or expression

1 Like

Alternatively you can use the “Format” component, no plugins required:

In the top panel, {0} means it should format “data 0”, :applies some formatting, and 0.00 gives you 2 digits.
Read more about it here.

~robin

1 Like

Another way, which I am mostly using, is writing round(x,2) at the *Expression field of the component (when available).

2 Likes

Like the Expression component mentioned by @seghierkhaled, the Eval component does the same thing. Both are found under ‘Math | Script’. No plugin:

round

By the way, there is a Round component but it behaves differently than the ‘round()’ function used in expressions… An unfortunate naming conflict.

In Pufferfish you also got the option to Truncate or round to Ceiling and Floor which is nice.

1 Like

I feel so stupid now…

1 Like

Don’t feel stupid. There are many ways and all are valuable info.

You can simplify it

1 Like