Rounding double to x decimals?

TBear
Hi.

I need to display some doubles in the status attribute window. Problem is that they're super long and ugly. How can I make a double have fewer decimals, preferably still as a double, but as a string would be fine as well.

Thanks.

jaynabonne
Here's a function that rounds to the specified number of decimal places and returns the result as a string:

  <function name="RoundToPlaces" parameters="value, places" type="string">
scale = pow(10,places)
return (ToString(round(value*scale)/scale))
</function>


If you want it as a double still, just remove the ToString (and change the function type).

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums