mirror of
https://github.com/TorqueGameEngines/Torque3D.git
synced 2026-07-14 08:04:40 +00:00
Round function can now round to number of digits
Changed round function to support optional n parameter to round to that many digits.
This commit is contained in:
parent
2efe1a9c0a
commit
686b9fced9
1 changed files with 11 additions and 6 deletions
|
|
@ -94,13 +94,18 @@ DefineConsoleFunction( mFloor, S32, ( F32 v ),,
|
||||||
return (S32)mFloor( v );
|
return (S32)mFloor( v );
|
||||||
}
|
}
|
||||||
|
|
||||||
DefineConsoleFunction( mRound, S32, ( F32 v ),,
|
|
||||||
"Round v to the nth decimal place or the nearest whole number by default."
|
DefineConsoleFunction( mRound, F32, ( F32 v, S32 n ), (0),
|
||||||
"@param v Value to roundn"
|
"Round v to the nth decimal place or the nearest whole number by default."
|
||||||
"@return The rounded value as a S32."
|
"@param v Value to round\n"
|
||||||
"@ingroup Math" )
|
"@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 ),,
|
DefineConsoleFunction( mCeil, S32, ( F32 v ),,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue