Author Topic: How does mfloor round?  (Read 1779 times)

Does it round up, round down, or round to the nearest integer? I need a percentage chance for one object to contain one of various materials, and I need to know if I can use the highest number in my random(min, max).

mFloor(%n) rounds down to the next integer. (3.99 --> 3)
mCeil(%n) rounds up to the next integer. (3.01 --> 4)
mFloatLength(%n,0) would round to the nearest integer. (3.99 --> 4, 3.01 --> 3)

k, got it. Lol, must sound like a stupid question.

so what's mFloatLength(3.5, 0)?

so what's mFloatLength(3.5, 0)?
4. .5 is half of the number and is rounded up.

so what's mFloatLength(3.5, 0)?
Have you taken more than first grade math?

Have you taken more than first grade math?
Was that really necessary?

Was that really necessary?
Yes, don't question when someone insults stupidity.

mFloor(%n) rounds down to the next integer. (3.99 --> 3)
mCeil(%n) rounds up to the next integer. (3.01 --> 4)
mFloatLength(%n,0) would round to the nearest integer. (3.99 --> 4, 3.01 --> 3)
I prefer making my own function for rounding to the nearest integer.

Code: [Select]
function mRound(%num)
{
    return mFloor(%num + 0.5);
}

I prefer making my own function for rounding to the nearest integer.

Code: [Select]
function mRound(%num)
{
    return mFloor(%num + 0.5);
}
That's a terrible rounding function, what would you even use that for?

I prefer making my own function for rounding to the nearest integer.

Code: [Select]
function mRound(%num)
{
    return mFloor(%num + 0.5);
}
i kinda feel like that's a waste considering that there's a function for it but i guess every man to his own

That's a terrible rounding function, what would you even use that for?
any number, it'll function the same as mFloatLength. If it's above .5 (the number it'll start to round from) it'll push it up to something that mFloor would round to the above integer. It works, but it's still unnecessary.

Oh christ disregard me I thought that it was return mFloor(%num) + 0.5;, lol

it would run slower, though

I prefer making my own function for rounding to the nearest integer.
Or you could just use mFloatLength because it's an engine function.

it'll function the same as mFloatLength.
It'll function the same as mFloatLength(%val, 0). mFloatLength is infinitely more useful because of the ability to specify which place to round to. I'm personally not a fan of shortening existing functions (i.e. fcbn) and don't support their use at all.