Results 1 to 2 of 2

Thread: Programming problem

  1. #1
    Join Date
    Jul 2006
    Posts
    142
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Talking Programming problem

    I hate myself asking this but I seem to have forgotten a simple programming technique...How do is check for set of logic ? i.e.

    if (a=10 & b= 23){
    .........}

    A & B is a set that goes togeather. What I want to do is also check for c & d set. the logic is :

    if a & b is true or if c & d is true then do something. How would i Do this? use case ? or if ((a=10 & b= 23) ||(c=15 & d= 3)) {} ...please help...

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    if((a && b) || (c && d)) {
      // ... do something ...
    }
    & is a bitwise AND operator in most C-based languages; don't confuse it with &&, the boolean AND operator.
    Code:
    5 && 8 // Returns true in languages that convert from int to bool; anything other than 0 is considered true
    5 & 8 // Returns 0, which equates as false in languages that convert from int to bool
    This should be in the "Other" forum.
    Last edited by Twey; 07-11-2006 at 04:52 PM.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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