MOD function does not work! So be warned!

Rob Cozens rcozens at pon.net
Fri Apr 5 12:04:17 EST 2002


>xTalks are purported to be 'typeless'. But they aren't.

Michael, et al,

Yes, and this mod issue is the result.

I can hear the conversation among Winkler, Atkinson, and other early 
HC team members:

"What do we do about the mod operator?  It's an integer operator in 
every other programming language; but if we restrict it to integers, 
we'll have to explain to people the differences between real numbers 
& integers...that might get them to thinking they're programming and 
scare them away.  So let's just accept decimals.  After all, there is 
nothing in the generic definition of 'remainder' that requires the 
dividend or divisor to be integers."      :{`)

 From the Rev dictionary:

"The mod operator evaluates to the remainder left over when one 
number is divided by another."

 From Funk & Wagnalls, remainder : "In division, the excess of the 
dividend over the product of the divisor by the integral part of the 
quotient."  Therefore remainder = dividend - 
(divisor*trunc(quotient)).  Trunc(quotient) = trunc(dividend/divisor) 
= dividend div divisor; so remainder = dividend - (divisor * 
(dividend div divisor))

That looks a lot like:

function myMod zaValue,zaBase
   return zaValue-((zaValue div zaBase)*zaBase)
end myMod

which I previously posted as being correct for integer values.  I 
rewrote Ian's original to call myMod instead of mod.  The results 
were the same.

I think Xtalk should follow normal programming convent and have mod 
reject non-integer values.  I'm ready to initiate a discussion on the 
topic on the Xtalk List, if someone would please send me subscription 
instructions.
-- 

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)



More information about the use-livecode mailing list