Results 1 to 10 of 10
Like Tree1Likes
  • 1 Post By KevinWorkman

Thread: Logical Operators

  1. #1
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Logical Operators

    How would I write an expression that evaluates to true if x is non-negative and y is negative when they have already been declared and assigned values?

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Logical Operators

    What have you tried? Where are you stuck?

    How do you test whether a value is negative or not?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  3. #3
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Re: Logical Operators

    Quote Originally Posted by KevinWorkman View Post
    What have you tried? Where are you stuck?

    How do you test whether a value is negative or not?
    I have been working with Equality and Rational Operators for the past few days, and this is my first time being exposed to this type of material. I have no idea how to test whether the value is negative or not, and the I have tried this:

    "!-x"
    "!-y"

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Logical Operators

    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Re: Logical Operators

    Quote Originally Posted by KevinWorkman View Post
    When it is below zero, right?

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Logical Operators

    Quote Originally Posted by Everyman View Post
    When it is below zero, right?
    Seems reasonable to me. Now do you see any comparative operators that test whether a value is less than another value?

    The tutorial I linked you to contains this page: http://docs.oracle.com/javase/tutori...bolts/op2.html
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  7. #7
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Re: Logical Operators

    Quote Originally Posted by KevinWorkman View Post
    Seems reasonable to me. Now do you see any comparative operators that test whether a value is less than another value?

    The tutorial I linked you to contains this page: Equality, Relational, and Conditional Operators (The Java™ Tutorials > Learning the Java Language > Language Basics)

    These?:

    "< less than"
    "<= less than or equal to"

  8. #8
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Logical Operators

    Quote Originally Posted by Everyman View Post
    These?:

    "< less than"
    "<= less than or equal to"
    What happened when you tried them?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  9. #9
    Everyman's Avatar
    Everyman is offline Member
    Join Date
    Feb 2012
    Location
    Everywhere
    Posts
    26
    Rep Power
    0

    Default Re: Logical Operators

    Quote Originally Posted by KevinWorkman View Post
    What happened when you tried them?
    Good things. Good things happened, sir. Thank you for all of your help.

    P.S.: This is the code that I used (x>=0 && y<0)

  10. #10
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,874
    Rep Power
    8

    Default Re: Logical Operators

    Awesome. Glad you got it sorted out.
    Everyman likes this.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. >>> and >> Logical operators
    By Playagood in forum New To Java
    Replies: 3
    Last Post: 02-19-2012, 04:07 AM
  2. string operators
    By cagipple in forum New To Java
    Replies: 5
    Last Post: 04-17-2011, 01:04 AM
  3. where exactly bit shift operators are useful?
    By sandeepsai39 in forum New To Java
    Replies: 6
    Last Post: 09-08-2010, 11:58 AM
  4. New to operators, need some help...
    By Stryker4526 in forum New To Java
    Replies: 4
    Last Post: 09-26-2009, 01:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •