View Full Version : The way of rounding off by MEL

10 October 2011, 07:24 AM

I would like to know good method to Rounding off by MEL
I think that there is no function appropriate for it.

Does someone know good way?

10 October 2011, 08:32 AM
Rounding off to what?
This MEL code:

float $prec=0.01;
float $a=1.016;
float $ar=floor(($a+(0.5*$prec))/$prec)*$prec;
print $ar;

yields 1.02 from 1.016. An input of 1.014 yields 1.01.

Use a different constant for $prec to round to other precisions.

<* Wes *>

10 October 2011, 10:44 AM
someone usually knows good way, and the best way to find that out is by using search:


CGTalk Moderation
10 October 2011, 10:44 AM
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.