Saturday, August 22, 2009

nice solution to rounding float in MEL

though I use MEL less and less this day, it's still nice to have some solution for some problem, like the one below.

If you want to round a float to nearest integer in python, just use round(4.33) . But we don't have round function in MEL. so we need to do some workaround. I found below technique in Maya Station blog :


float $float = 3.14159265;

floor ( $float + 0.5 );

// Result: 3