Re: simple eurphoria question

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

Chris Bensler wrote:
> 
> Mark K. Akita wrote:
> > 
> > Hi John,
> > 
> > This function seems to work as well for converting atom to integer.
> > 
> > }}}
<eucode>
> > 
> > function int(atom a)
> > 
> > 	return floor(a)+(a<0)
> > 
> > end function
> > 
> > </eucode>
{{{

> > 
> > Good luck!
> > 
> > Mark K. Akita
> > <a href="http://marksarts.blogspot.com/">http://marksarts.blogspot.com/</a>
> 
> That's what I thought Mark, but it's incorrect. :)
> Try with this set of numbers: 1, 1.1, 1.9, 2, -1, -1.1, -1.9, -2
> 
> Mike Nelson, or Larry Miller's solutions are correct.
> 
> Chris Bensler
> ~ The difference between ordinary and extraordinary is that little extra ~
> <a href="http://empire.iwireweb.com">http://empire.iwireweb.com</a> - Empire
> for Euphoria
Good catch Chris, 
OK.. how about this function instead

function int(atom a)

	return a-remainder(a,1)

end function


This should work with negative numbers that already are integers.

Mark K. Akita
http://marksarts.blogspot.com

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

Search



Quick Links

User menu

Not signed in.

Misc Menu