why does:
My assumption was that it would be false because of a remainder of 15.
I liked this applet: http://www.openprocessing.org/visuals/?visualID=3066
When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:My assumption was that it would be false because of a remainder of 15.
If you use Long_division...
Author of ExamLab  a free SCJP / OCPJP exam simulator
What would SCJP exam questions look like?  OCPJP Online Training  Home  Twitter  How to Ask a Question
Generally speaking, Y mod X will only give you values from 0 to X1 (assuming Y is a nonnegative integer value)
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
I mean, if you do long division, you do have a remainder of 15 (unlike Devaka's beautiful picture shows).
I'm confused why this is and who thought it would be a good plan to say they'll make the expression evaluate differently if it is with a 0 divisor.
When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:So the language specification states that the remainder when dividing 0 by 15 is 0?
I mean, if you do long division, you do have a remainder of 15 (unlike Devaka's beautiful picture shows).
I'm confused why this is and who thought it would be a good plan to say they'll make the expression evaluate differently if it is with a 0 divisor.
Is 0 the divisor or the dividend? Up until now, I thought we were talking about 0/15 rather than 15/0. For 0/15, 0 is the dividend, and 15 is the divisor. The quotient is 0, and the result is 0.
As a general rule, the dividend should equal the divisor times quotient, plus the remainder. For example if we divide 14 by 3, we get a quotient of 4 with a remainder of 2. If we multiply divisor 3 by quotient 3, we get 12, and if we add the remainder 2, we get 14, which is the dividend.
How does this apply to 0/15? Can we agree the quotient here is 0? If you say the remainder is 15, then when we calculate (divisor * quotient) + remainder we get (15 * 0) + 15 = 15  that's supposed to add up to the dividend. Except that the dividend was 0. So how could the remainder have been 15? That doesn't work.
Instead, the remainder is 0. Now (divisor * quotient) + remainder = (15 * 0) + 0 = 0, which was the dividend. As we expect. All is right in the world again.
So, defining 0/n to have a remainder of 0 is not just a Java specification thing. It's the way remainder has always been defined, as far as I know.
Mike Simmons wrote:
So, defining 0/n to have a remainder of 0 is not just a Java specification thing. It's the way remainder has always been defined, as far as I know.
What? I'm not a math major and I'm incredibly confused by your whole post.
If you have no pies and you try to divide them to feed 15 hungry friends, you have no friends fed with a remainder of 15 hungry friends.
A remainder is how much is left over in the dividend after dividing into the divisor, right?
Fifteen goes into zero no times with a remainder of fifteen.
So saying that the modulo is "the remainder" is not correct?
When you do things right, people won't be sure you've done anything at all.
Janeice DelVecchio wrote:If you have no pies and you try to divide them to feed 15 hungry friends, you have no friends fed with a remainder of 15 hungry friends.
You have 15 hungry friends, but they aren't the remainder. When you divide 0 pies among 15 friends, they each get 0 pies (the quotient) and you have 0 pies left over (the remainder). The remainder in this problem should be the number of pies left over, not the number of friends.
Janeice DelVecchio wrote:A remainder is how much is left over in the dividend after dividing into the divisor, right?
Yes  what's left over from the dividend. Which was zero pies. The 15 friends were never part of what was being divided up  they were who it was divided up amongst.
Janeice DelVecchio wrote:Fifteen goes into zero no times with a remainder of fifteen.
Obviously, I still disagree.
Janeice DelVecchio wrote:So saying that the modulo is "the remainder" is not correct?
It is correct, at least for positive numbers. (There may be a subtle definition issue for negative numbers; don't remember and don't care at the moment.)
0 mod 15 = 0 % 15 = 0. Which is the remainder.
I thought it was what "couldn't fit" and is thereby left over... and I never really thought (since third or fourth grade) about how the number was derived.
I suppose I never thought about it critically. It makes sense.
When you do things right, people won't be sure you've done anything at all.
20 dollars divided by 3 people = 6 dollars per person, with 2 dollars left over.
in this example, 20 is the dividend, 3 the divisor, 6 the quotient, 2 the remainder.
Note that the remainder and the dividend have the same 'units'  dollars.
In other words:
In you example, you have 0 dollars (dividend) to divide among 15 people (divisor). The remainder must be the same units as the dividend.
so, 0 / 15 means everyone gets 0 dollars, and then you have 0 dollars left over.
If you had 3 dollars, everyone would still get 0 (since you have to be fair and give everyone the same), and now you have 3 dollars left over.
There are only two hard things in computer science: cache invalidation, naming things, and offbyone errors
Happiness is not a goal ... it's a byproduct of a life well lived  Eleanor Roosevelt. Tiny ad:
The WEB SERVICES and JAXRS Course
https://coderanch.com/t/690789/WEBSERVICESJAXRS
