How to divide a NumberValue value to whole numbers (giving me both results)?

Well, I want to divide a NumberValue in half giving me an integer result. Divide in half by giving me a whole number, I already know how to do it, but I want you to give me both results, for example: I have the number 11, and I want to divide it in half by giving me a whole number; after dividing it with math.floor (11/2), it gives me 5, but it doesn’t give me the other 6 which is what I also want to get

3 Likes

Subtract the floored number from the higher number.

local numberToDivide = 11
local half = math.floor(numberToDivide / 2)
local otherHalf = numberToDivide - half

Or just use math.ceil:

local numberToDivide = 11
local half = math.floor(numberToDivide / 2)
local otherHalf = math.ceil(numberToDivide / 2)
6 Likes