Conditional IF Brain Fart

This is a discussion on Conditional IF Brain Fart within the C Programming forums, part of the General Programming Boards category; In trying to check that R, G, B gives white then would this statement suffice: Code: if (R == G ...

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    28

    Thumbs down Conditional IF Brain Fart

    In trying to check that R, G, B gives white then would this statement suffice:

    Code:
    if (R == G == B == 255)
    {
    ....
    }

    Thanks
    Last edited by paulogrady; 04-12-2009 at 11:04 AM.

  2. #2
    Chinese pâté foxman's Avatar
    Join Date
    Jul 2007
    Location
    Canada
    Posts
    404
    No.

    Code:
    if (R == 255 && G == 255 && B == 255)
    {
    }
    I hate real numbers.

  3. #3
    Registered User
    Join Date
    May 2008
    Posts
    28

    Thumbs up

    Thanks for the fast answer !

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,939
    No, you are looking to use ||, e.g., R == 255 || G == 255.

    EDIT:
    Oh yes, since you actually want all three to match 255, then yes && would be correct, not ||.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  5. #5
    Making mistakes
    Join Date
    Dec 2008
    Posts
    476
    @Above: As far as I know, white is when (R == 255 && G == 255 && B == 255).

    And like loxman said compare all to 255 or

    if (R == G && G == B && B == 255) ...
    Last edited by Brafil; 04-12-2009 at 11:09 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. brain fart
    By Gardul in forum C++ Programming
    Replies: 6
    Last Post: 10-26-2005, 08:49 AM
  3. Re: Girlfriend Post
    By PsychoBrat in forum A Brief History of Cprogramming.com
    Replies: 57
    Last Post: 05-13-2002, 06:11 AM
  4. Brain fart
    By Govtcheez in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 08-30-2001, 12:40 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21