..:D&G:.. Posted April 6, 2015 Share Posted April 6, 2015 Hello guys, from the maths (distance*0.6) I get a decimal number with 1 decimal place, is there anyway of rounding that up? Thanks. Link to comment
xXMADEXx Posted April 7, 2015 Share Posted April 7, 2015 math.floor Actually, to round up it's math.ceil or you could use Math.round. Link to comment
WhoAmI Posted April 7, 2015 Share Posted April 7, 2015 Actually correct one is math.floor ( number + 0.5 ) or math.ceil ( number - 0.5 ) Link to comment
Et-win Posted April 7, 2015 Share Posted April 7, 2015 Actually correct one is math.floor ( number + 0.5 ) or math.ceil ( number - 0.5 ) He wants always its rounding up Link to comment
WhoAmI Posted April 7, 2015 Share Posted April 7, 2015 Actually correct one is math.floor ( number + 0.5 ) or math.ceil ( number - 0.5 ) He wants always its rounding up I'll show you something. local n = 5.9; print ( math.floor ( n ) ); Output: 5 local n = 5.9; print ( math.floor ( n + 0.5 ) ); Output: 6 For correct rounding number you have to add this 0.5. Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now