Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Is there a way to round a number up if it's over 0.5?

I know of math.ceil and math.floor but those round the number up and down no matter what the decimal is. Is there a way to round a number to it's closest integer?

1 answer

✓ Accepted answer

You want

  • 0.49 --> 0
  • 0.51 --> 1
  • 1.49 --> 1
  • 1.51 --> 2
  • 2.49 --> 2
  • 2.51 --> 3

This looks a lot like math.floor. Each one on the left is just off by 0.5.

In fact, the answer is just

math.floor(x + 0.5)

2 comments

0

But it says OVER .5!

0

Thank you

This discussion is preserved as it was. New answers, comments, and votes are closed.