Newbie question !( 1 || 0 ) - ?

This is a discussion on Newbie question !( 1 || 0 ) - ? within the C++ Programming forums, part of the General Programming Boards category; Yeh..i think ive got u there now Lithorien, thanx for the info.. so as far as I can gather..i was ...

  1. #16
    Registered User
    Join Date
    Mar 2005
    Posts
    39
    Yeh..i think ive got u there now Lithorien, thanx for the info..

    so as far as I can gather..i was right in some ways but wrong in stating that there is no technical XOR operator!

    KK..cool

    cheers, and thanx again

    Alex

  2. #17
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Quote Originally Posted by Thantos
    Of course what Salem is failing to state is that it's bitwise XOR
    What other kind is there?

  3. #18
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Logical....

    Logical XOR doesn't exist in C++. Of course it's simple to implament

  4. #19
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    Quote Originally Posted by Thantos
    Logical....

    Logical XOR doesn't exist in C++. Of course it's simple to implament
    I thought it was the same thing - i.e. that they were interchangable. I mean the following works:

    Code:
    if (i == 2 | j == 6)
    ...because you're applying bitwise logic to the conditions. I think it will even drop short-circuiting in this case (should you want to).

    So you could apply logical XOR by the same token...

  5. #20
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    Bitwise and logical are not the same.

    Take:
    Code:
    if ( 10 && 5 )
    This is true
    Code:
    if ( 10 & 5 )
    This is false

    Obviously they aren't interchangeable.

    Now when you get down to just boolean values they do become interchangeable but not until you get to that point.

    I think it will even drop short-circuiting in this case (should you want to).
    AFAIK short-circuit evaluation is always done when possible

  6. #21
    Budding Synth Programmer samGwilliam's Avatar
    Join Date
    Feb 2002
    Location
    Trefforest
    Posts
    368
    I meant with regards to conditions, so yes, Booleans only.

    And I just tested it on my compiler (MSCV++ 6.0) - it doesn't do short circuiting at all!

  7. #22
    & the hat of GPL slaying Thantos's Avatar
    Join Date
    Sep 2001
    Posts
    5,681
    sigh...
    Code:
    if ( 10 && 5 )
    is a condition and it's valid. Conditions are not boolean only. They will resolved down to booleans but that doesn't mean it started with and only contains booleans.

    And I just tested it on my compiler (MSCV++ 6.0) - it doesn't do short circuiting at all!
    Well what did you test?

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Stupid Newbie question
    By TimL in forum C++ Programming
    Replies: 4
    Last Post: 07-22-2008, 04:43 AM
  2. Newbie with Very Newbie Question
    By Jedi_Mediator in forum C++ Programming
    Replies: 18
    Last Post: 07-01-2008, 08:00 AM
  3. Quick Ques on String Manipulation
    By ckuttruff in forum C Programming
    Replies: 8
    Last Post: 06-22-2008, 09:32 PM
  4. newbie: array question :(
    By cstudent in forum C Programming
    Replies: 2
    Last Post: 04-09-2008, 06:46 AM
  5. Optimization of code
    By dpro in forum C++ Programming
    Replies: 5
    Last Post: 10-28-2002, 03:01 PM

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