Control Roundoff/ Decimal

Hello all,

I need some assistance with a situation in my code. After using Math.round, I noticed that the end result still displays decimals, and I want to ensure the output shows only one decimal place. Could you guide me on how to control this?

Thank you in advance for your support!

Best regards,
Vijay

Hi,

I typically use this node from spring nodes. Let’s me specify amount to round and converts it to a string.

Hope this helps!

1 Like

Just to clarify what’s going on, this is how doubles get converted to strings. The string always converts to 6 decimal places for a double since that’s how the value is stored. You either get 6 places with a double or 0 with an integer. Rounding only rounds the value, not the precision. You can always trim the string afterwards, but a custom node is better.

2 Likes

Hi,

It’s working perfectly. Thanks for the suggestion!

Best regards,
Vijay

Here from some OOTP nodes,

1 Like