PDA

View Full Version : Expresssion for rounding decimals


Darter
11-25-2005, 02:05 PM
Here's an expression for rounding decimal values. It outputs a String value and works for numbers beyond the -32,768 to 32,767 range. The number of decimal places can be set from 0 to 3.

I've spent some time testing it but if any errors turn up, feedback would be appreciated.

EDIT: See below for updated file.

cbowyer
11-25-2005, 05:32 PM
Hello Darter

Thanks for the update. I am currently working on a C4D tutorial DVD, would you object to letting me using this file as part of my xPresso demonstration? I'd be happy to give you credit for the contribution.

Darter
11-25-2005, 09:43 PM
Thanks, you're welcome to use the expression on the DVD. Credit would be appreciated.

Another point about the expression: it will always output the same number of digits after the decimal point for a given setting e.g. a setting of 3 will cause 23.1 to be output as 23.100. The 3 decimal places setting was included to provide an alternative to bypassing the expression if this behaviour is desired.

Darter
11-26-2005, 02:49 PM
I've added a Cull Zeros setting to the expression.

When this is unchecked, the number of digits after the decimal point will always equal the Decimal Places value. When the option checked, redundant zeros will be culled from the end of the output value.

Again, I would appreciate feedback if any errors are encountered when using the expression.

CGTalk Moderation
11-26-2005, 02:49 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.