Re: simple eurphoria question
- Posted by c.k.lester <euphoric at cklester.com> Dec 05, 2006
- 698 views
Alexander Toresson wrote: > Evan Marshall wrote: > > john thomas wrote: > > > > > > can someone please tell me how to get the integer part of a number in an > > > atom > > > in order to assign it to an integer variable > > > > atom x > > integer y > > x = 1.1 > > > > y = floor(x) > > Yes, that will get the integer part of positive numbers, but it won't get the > integer part of negative numbers. For example, -1.1 will be rounded down to > -2. I'm afraid you'll have to use some if statements to make it work for > negative > numbers too (ie if it's a negative number, do the opposite of floor(), which > could be named roof() and be a new function you could implement). 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