Please always provide a subject line. Otherwise it is very hard to follow threads.
Noufal Ibrahim wrote: > Kopalle Narasimha wrote: > >> Hello, Everyone. >> >> I have a strange problem with floating point numbers. Please help me. >> I tried the following at the python prompt: >> >> Case 1: >> >>>>> 4.5/2.0 #Gives quotient >>>>> >> Answer: 2.25 >> >> Case 2: >> >>>>> 4.5%2.0 #Gives Remainder >>>>> Despite what the documentation says, the modulo operator does not return a remainder! Notice: >>> [x % 3 for x in range(-5,5)] [1, 2, 0, 1, 2, 0, 1, 2, 0, 1] For negative values of the left argument the result is NOT the remainder. The literature seems very confused about this, using "remainder" when it is NOT the case. What's worse, in some languages the mod operator DOES return the remainder. [snip] -- Bob Gailer 510-978-4454 _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor