Author Topic: Make Integer?  (Read 802 times)

'Ello. Quite simple question really, but how do I covert a decimal value (such as position) to an integer value?

Hurr, I'm stupid.

mFloor and mCeil

:3

Edit: or not?

Re-Edit: or so. It appears that I am a fecktard. Disregard this tawpic :c

function Round(%num)

     if(%num - mFloor(%num) < 5) 
          return mFloor(%num); 
     else 
          return mCeil(%num); 
« Last Edit: March 03, 2010, 07:38:58 PM by cucumberdude »

function Round(%num)

     if(%num - mFloor(%num) < 5
          return mFloor(%num); 
     else 
          return mCeil(%num); 

5? Why 5? Here's how I would do it:
Code: [Select]
function Round(%num)
{
   %floor = %num - mFloor(%num);
   %ceil = %num - mCeil(%num);
   if(%floor >= mAbs(%ceil))
      return mCeil(%num);
   else
      return mFloor(%num);
}

5? Why 5? Here's how I would do it:

function Round? Why function Round? Here's how I would do it:

Code: [Select]
mFloatLength(%num,0)

function Round? Why function Round? Here's how I would do it:

Code: [Select]
mFloatLength(%num,0)
Well, yes, but I was just showing him how I would make my own round function.

Well, yes, but I was just showing him how I would make my own round function.
...?
function Round(%num)
{
         return mFloatLength(%num,0);
}

Nevermind that one.
Nevermind that nevermind.
« Last Edit: March 05, 2010, 04:03:00 PM by -Jetz- »

...?
Code: [Select]
function Round(%num)
{
         return mFloatLength(%num,0);
}
That doesn't round numbers...
« Last Edit: March 05, 2010, 09:43:08 AM by Destiny/Zack0Wack0 »

That doesn't round numbers...
Oh, whoops, I just assumed that his way rounded the number.
Code: [Select]
function mRound(%num)
{
return (%num - mFloor(%num) < 0.5) ? mFloor(%num) : mCeil(%num);
}

Woops, my mistake. mFloatLength actually does round numbers haha. I was thinking of a different function.