There was a discussion about this (or perhaps it was floor) on Direct-l last year or the year before. Someone posted a very fast, elegant solution using bitXor, or something. There are other ways as well, but they need a conditional to handle differences between positive and negative numbers.

Here are the ones I use:

on ceiling me, aNumber
  if aNumber >= 0 then return integer(aNumber + .49999999)
  --integer rounds n.5 up to n + 1, but rounds -n.5 down to -n - 1
  return integer(aNumber + .5)
end ceiling

on floor me, aNumber
  if aNumber > 0 then return integer(aNumber - .5)
  --integer rounds n.5 up to n + 1, but rounds -n.5 down to -n - 1
  return integer(aNumber - .49999999)
end floor

Regards,

Daniel

On Jan 26, 2004, at 9:10 AM, Mendelsohn, Michael wrote:

Hi all...

I want to automatically convert a float to the next highest integer.
Flash has the Math.ceil() method, so what's the most efficient way to do
this in Lingo?


I appreciate any responses, and have a superb day.

Thanks,
Michael M.


[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]



[To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]

Reply via email to