I’m currently working on a script that devides the player count by two, but I don’t know how to devide an odd number without the decimal place in each number.
I get: 5 / 2 = 2.5
But I want: 9 / 2 = 2 and 3
Does anyone know how to solve this?
You can use a symbol cant remember the name but it looks like a sideways percent
Lemme try and find the name rq
First of all, this topic belongs in #help-and-feedback:scripting-support .
As to your problem, there are three functions that could solve your problem. These are: math.floor, math.ceil, and math.round.
Here’s what each does:
Floor: Lower a decimal to whole number (ex. 1.75 → 1)
Ceil: Raise a decimal to whole number (ex. 1.25 → 2)
Round: Rounds the decimal to the nearest whole number (ex. 1.5 - > 2)
Hope this helps!
More info. Its the thing you use when you factor stuff. Ex: if the number is divisible by two (print) its even. Else print its odd. (instead of divisible put the other symbol I cant find ;-; )
another correction ( : P ) it looks like a 0 / 0 but its straight
local lower = math.floor(5/2) -- 2
local upper = math.ceil(5/2) -- 3
Change this post’s name to “Divide an odd number”…I noticed a typo.
It’s the modulo operator, and it’s just a normal percentage symbol. For this case, as others are saying, the solution would be flooring or rounding the number