All numbers are divisible by any other number as long as that other number
isn't zero.
I suspect, though, you mean "evenly divisible", such that there's no remainder.
In that case, this is how you do it:
What you want to do is to see if the result matches the result when
converted to an integer. Example:
if (a / b) = integer(a / b) then
-- Put evenly divisible!
end if
If a=8.0 and b=3, then the result would be 2.6667, and 2.6667 would not
equal integer(2.6667), which is 2, so it would fail.
Some might suggest checking the modulus of the number. The mod of evenly
divisible integers is 0. This works, EXCEPT you must know for a fact that
you are comparing integers. If they are float values (like 8.2) then it
won't work.
If they are straight integers, then you can do this:
if (a mod b) = 0 then
-- Put evenly divisible!
end if
- Tab
At 12:50 PM 7/16/01 -0400, Bill Numerick wrote:
>Hey All,
>
>How can I find out if something is divisable by a certain number?
[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi To post messages to the list,
email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo. Thanks!]