Expresssion for rounding decimals

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  11 November 2005
Expresssion for rounding decimals

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.

Last edited by Darter : 11 November 2005 at 02:52 PM.
  11 November 2005
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.
  11 November 2005
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.

Last edited by Darter : 11 November 2005 at 10:11 PM.
  11 November 2005
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.
  11 November 2005
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 02:51 PM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.