MOD function does not work! So be warned!

David Vaughan drvaughan55 at mac.com
Wed Apr 3 17:40:00 EST 2002


On Thursday, April 4, 2002, at 01:59 , Rob Cozens wrote:
snip
>
> A final note:  Someone else mentioned the mod operator is supposed to 
> be used with integers, so anyRealValue mod anyBase is non-sequitur. I 
> didn't see anything in the documentation restricting the use of mod to 
> integers; OTOH, I can't recall having a practical need for the mod of a 
> non-integer in 25+ years of programming.

Rob

The someone else was me, and since another writer made a similar point 
about my comment I should clarify that I did not make it in relation to 
Rev (and hence the documentation makes no such statement) but to the MOD 
function as it was initially implemented (so far as I know) in the 
languages of 25+ or even 35+ years ago. I was talking about distant 
antecedents rather than current usage.

OTOH, if we wish to use a comparison where the significant result is an 
integer then isn't it natural to ensure we are dealing with an integer? 
[This is a rhetorical question :-)]  Changing the last line of your 
example to
put (var1 = var2) && ((round(var1) mod 5)= (round(var2) mod 5))
does this.

I am of the view that the MOD function works no worse than I might 
expect it to on a computer, if less well than I would prefer. I don't 
like surprises of this nature either but that is one reason I act to 
avoid them.

regards
David
>
>
> --
> Rob Cozens
> CCW, Serendipity Software Company
> http://www.oenolog.com/who.htm
>
> "And I, which was two fooles, do so grow three;
> Who are a little wise, the best fooles bee."
>
> from "The Triple Foole" by John Donne (1572-1631)
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution
>




More information about the use-livecode mailing list