From: Sean O'Dell Date: 2002-03-01T05:18:51+09:00 Subject: Re: Correct use of % (modulus) operator? "Dan McNulty" wrote in message news:ff217e22.0202281135.aec6da8@posting.google.com... > Coming from a C background, I expected "%" to yield a remainder. > > 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 In C, "5 % 2" yields 1. 2 goes into 5 only twice evenly, leaving a remainder of 1. The expression for your result is "(5 / 2) % 1". Sean