Jump to content

[HELP] Rounding a number


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...