dmcnulty / mindspring.com (Dan McNulty) writes: > Coming from a C background, I expected "%" to yield a remainder. Coming from a C background, I would have expected you to expect this result! ;) > But the code: > print "4 mod 2: ", 4.0 % 2.0, "\n" > print "5 mod 2: ", 5.0 % 2.0, "\n" > > gives me: > 4 mod 2: 0.0 > 5 mod 2: 1.0 > > I was expecting a result of "0.5" for 5 % 2, as 5.0 / 2.0 = 2.5 > > This isn't covered very well in the books I have, nor can I find much > on the 'net. I obviously have missed something rather fundamental. 5 % 2 = 1 because 2 goes into 5 twice, with 1 remaining. IOW, the % operator is for *integer* remainder only. (just as in C) ttyl, -- Josh Huber