Rounding Numbers in Max

Apr 17, 2010 at 3:27pm

Rounding Numbers in Max

Hi there, is it possible to round a decimal number to the nearest whole number.

So if i inputted 60.9 and 70.2, it would always output 70.

Thanks.

#49804
Apr 17, 2010 at 3:37pm

[+ 0.5] >> [int]

#178852
Apr 17, 2010 at 3:40pm

Sure – slap an integer number box on the float output, which truncates. If that doesn’t float your boat and you want to round “like humans do,” then add. .5 and then slap an integer number box on the float output.

#178853
Apr 17, 2010 at 3:42pm

or just use [round]

#178854
Apr 17, 2010 at 3:43pm

The [round ] object is more convenient.

#178855
Apr 17, 2010 at 4:09pm

Thanks everyone, feel a bit silly now :P

#178856
Apr 18, 2010 at 12:14pm

[expr (int($f1-0.5))*($f1<0) + (int($f1+0.5))*($f1>=0)]

#178857
Apr 23, 2010 at 10:25pm

a more concise one int($f1 + ($f1 > 0) - 0.5).

#178858
Apr 28, 2010 at 5:20pm

nice one, danke ej

#178859

You must be logged in to reply to this topic.