Re: more RANT

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

A simple function would be:

function DivEvenly(atom num, atom den) -- num is Numerator   den is
Denominator
  return num/den = floor(num/den)
end function

The return value will be zero if it doesn't divide evenly and nonzero if it
does.

So,

If DivEvenly(10, 5) then
  puts(1,"Yes")
end if

will print "Yes"
and

If DivEvenly(23, -14) then
  puts(1,"Yes")
end if

will print nothing.

This may be faster than using integer() or remainder(), although it does use
floor().
You could also just use the formula num/den = floor(num/den) in the actual
line testing the two numbers instead of putting it into a function.  That
might also speed things up.

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

Search



Quick Links

User menu

Not signed in.

Misc Menu