Re: simple eurphoria question

new topic     » goto parent     » topic index » view thread      » older message » newer message

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).

Regards, Alexander Toresson

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu