Re: simple eurphoria question
- Posted by Mike Nelson <mikestar13 at sbcglobal.net> Dec 07, 2006
- 720 views
c.k.lester wrote: > I wrote a function just for this purpose. It's called > round_this_number_toward_zero_remember_that_negative_numbers_are_screwy(). > > I sometimes wonder if it's worth typing all that out just for > > if x < 0 then > return floor(x+1) > else > return floor(x) > end if This is not quite correct. if x is say, -2, it will return -1 rather than the correct -2. This will work:
if integer(x) then return x elsif x<0 then return floor(x+1) else return floor(x) end if }}}