From 686b9fced931833fc30e043472e92a6709cdccbf Mon Sep 17 00:00:00 2001 From: Nathan Bowhay Date: Tue, 3 Feb 2015 11:52:06 -0800 Subject: [PATCH] Round function can now round to number of digits Changed round function to support optional n parameter to round to that many digits. --- Engine/source/math/mConsoleFunctions.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/Engine/source/math/mConsoleFunctions.cpp b/Engine/source/math/mConsoleFunctions.cpp index 1a11fe23e..f9b352c28 100644 --- a/Engine/source/math/mConsoleFunctions.cpp +++ b/Engine/source/math/mConsoleFunctions.cpp @@ -94,13 +94,18 @@ DefineConsoleFunction( mFloor, S32, ( F32 v ),, return (S32)mFloor( v ); } -DefineConsoleFunction( mRound, S32, ( F32 v ),, - "Round v to the nth decimal place or the nearest whole number by default." - "@param v Value to roundn" - "@return The rounded value as a S32." - "@ingroup Math" ) + +DefineConsoleFunction( mRound, F32, ( F32 v, S32 n ), (0), + "Round v to the nth decimal place or the nearest whole number by default." + "@param v Value to round\n" + "@param n Number of decimal places to round to, 0 by default\n" + "@return The rounded value as a S32." + "@ingroup Math" ) { - return mRound(v); + if(n <= 0) + return mRound(v); + else + return mRound(v, n); } DefineConsoleFunction( mCeil, S32, ( F32 v ),,