There is no emoticon for what I am feeling!
JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
There is no emoticon for what I am feeling!
Originally posted by Stuart Goss:
Sorry, I see no reason why the number theory modulo operator may not return negative values ...
Originally posted by Marilyn de Queiroz:
Apparently modulo is defined differently in different languages. In comparing Python with C++, for example, we see the following:
Java was, in many ways, modelled after C/C++ (to entice them to switch to Java).
Originally posted by Jeff Albrechtsen:
Quick, what's -1/2?
To summarize (I'm quoting the JSL, because I don't trust my memory:
"Integer division rounds towards 0." (�15.17.2) (So -1/2 is 0, not -1) "The binary %
Originally posted by Adam Price:
Java was, in many ways, modelled after C/C++ (to entice them to switch to Java).<hr></blockquote>
I can deal with the C/C++ convention, (and the Java one) but that python output is weird!
That's good to know.
Thanks for your thoughts, everyone.
-Adam[/QB]
[OCA 8 Book] [OCP 8 Book] [Blog] * SCJP (1.4, 1.6) * OCAJP 8 * OCPJP 8
Originally posted by Scott Selikoff:
In terms of mathematical correctness, modular arithemetic is defined on a ring such that in the example -12 modulo 10, the class of numbers defined by -12 is congruent to the class of numbers defined by 8. Meaning on the ring 10, all arithmetic operations would be the same regardles of which number you chose, -2 or 8, for the operation
Java picks the leastmost positive number for the ring, which is also what you commonly use to represent that class of numbers in mathematics, ie, -12, -2, 8, 18, and 28 on ring 10 would be represented as {8}.
Originally posted by Adam Price:
Unless you are talking about a different way to get the congruence class than [code[-12 mod 10[/code]. It truly is returning the remainder, not the least positive member of the congruence class
[OCA 8 Book] [OCP 8 Book] [Blog] * SCJP (1.4, 1.6) * OCAJP 8 * OCPJP 8
Don't get me started about those stupid light bulbs. |