Winston Gutkowski wrote:
Campbell Ritchie wrote:I see they are calling it complement. Still probably in accurate. Negation is better.
Personally, I like just calling it "not", especially for a boolean. 'Compliment' is somewhat vague, and in the context of '~', it's actually a 1s-compliment op.
Winston
Greg Brannon wrote:Booleans can get our brains twisted the more we think about them.
2.5 >= 8 is false. 2.5 is clearly NOT greater than or equal to 8.
!( false ) = true. obvious?
b2 = b1 || true
b1 = false. a given
b2 = false || true. If either this OR that is true, the result is true.
b2 = true.
Jeff Verdegan wrote:
Melissa Nikolic wrote:
Thank you for your clear explanation. Frankly, telling a newbie to go to the Java documentation is like telling an introductory biology student to go find the answer to a question in a peer reviewed journal. It seems a bit unhelpful. But since I am used to peer reviewed journals I should be able to muck through the documentation.
Regards,
M
Well, it's just two different approaches. There's a continuum of how much direct help can be offered vs. just pointing someone in the right direction and letting them try to figure it out on their own, and, other than not handing over full code solutions, there are as many different opinions on what kind of help should be given as there are people giving help. For beginners, I usually just provide the JLS as additional information, since a lot of it can be difficult reading, even for those with more experience. I guess Campbell felt it was better for you to read the relevant section of the JLS first, and then ask more specific questions if they arise from there. Either way, we're all just trying to help you learn.
Jeff Verdegan wrote:
Melissa Nikolic wrote:Hi again,
I wanted to confirm a particular conversion example and its meaning.
If I initialize the following:
short h = 40;
My Java book says that this is ok because int is converted to a short.
while...
h = h + 2; is not okay because "cannot assign an int to short"
Is this an error because the first example is explicitly assigned to a short while the second example is not explicitly assigned and therefore cannot be promoted implicitly?
Case 1: 40 is an int. Since it is a compile-time constant that fits into a short, a narrowing conversion is automatically applied and the value (short)40 is stored in h. No promotion occurs.
Case 2: h + 2 is short + int, so the value of h on the RHS is promoted to an int, and the result of h + 2 is an int. Since h + 2 is not a compile-time constant, no automatic narrowing is done, and it's an error because we're trying to stick an int into a container meant to hold only a short.
Campbell Ritchie wrote:I have already told you the Java Language Specification is difficult to understand, but that is where you will find the details.
Campbell Ritchie wrote:What does your book say the positive operator does? Then check that against the Java Language Specification (JLS). The JLS is not easy to understand, however.
Jeff Verdegan wrote:
Melissa Nikolic wrote:Hello,
I wanted to first thank the moderators for a place where newbies can come and ask questions without being berated or chastised (sadly I have seen this on numerous sites).
To be fair, people are not usually chastised simply for asking newbie questions. They will be spanked a bit on some sites for failing to do any research on their own before posting, for asking others to do their work for them, or for copping an attitude of entitlement. This place just goes out of its way to be explicitly friendly more than most sites, while other sites tend to be more down to business without any frills.
Joanne Neal wrote:
Melissa Nikolic wrote:.unary arithmatic operators (addition + and subtraction -)
The unary arithmetic operators are ++ and --. They increment or decrement the variable by 1.
They are unary because they only require one operand e.g. i++, --x
Bear Bibeault wrote:Addition and subtraction are binary operators.