MOD function does not work! So be warned!

Yates, Glen JAMES.G.YATES at saic.com
Thu Apr 4 10:58:01 EST 2002


Rob,

I believe the bottom line is that MOD works for integers, if you want to
perform mod on floating point numbers you'll have to write your own routine.

Here's some psuedo code off the top of my head for (x mod y = z) where x, y,
and z are floats:

	put x / y into z
	put trunc(z) into zWhole
	put z - zWhole into z
	put z * y into z

The value in z should now be x mod y.

Note, I haven't tested this, and I dont know how it will work with negative
numbers (as I just now thought of considering them), but this should at
least be a starting point for someone to write a real function to do it. I'd
do it myself, but I've never had a need to do mod with non-integers.

-Glen Yates

> >MOD is working. = is working.
> 
> Michael,
> 
> MOD is NOT working: anyNumber mod 5 CANNOT = 5.
> 
> -- 
> 
> Rob Cozens



More information about the use-livecode mailing list