how to complement

This is a discussion on how to complement within the C++ Programming forums, part of the General Programming Boards category; is the "~" a complement? how do i use it? can i use it like this.... bool flag = true; ...

  1. #1
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195

    how to complement

    is the "~" a complement? how do i use it? can i use it like this....

    bool flag = true;

    flag ~= flag;
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  2. #2
    Registered User stautze's Avatar
    Join Date
    Apr 2002
    Posts
    195
    thats why it didn't work....

    thanks.
    'During my service in the United States Congress, I took the initiative in creating the Internet.' - Al Gore, March 9, 1999: On CNN's Late Edition

  3. #3
    S Sang-drax's Avatar
    Join Date
    May 2002
    Location
    Göteborg, Sweden
    Posts
    2,072
    No, why it didn't work is because ~= is not an operator in C++.

    You could have written:

    a = ~a;

    But that is not recommended.

    warning C4804: '~' : unsafe use of type 'bool' in operation
    warning C4800: 'int' : forcing value to bool 'true' or 'false' (performance warning)
    Last edited by Sang-drax : Tomorrow at 02:21 AM. Reason: Time travelling

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. sscanf and 32 bit two's complement
    By The Urchin in forum C++ Programming
    Replies: 4
    Last Post: 10-15-2006, 02:17 AM
  2. two's complement question
    By NetWeirdo in forum C Programming
    Replies: 1
    Last Post: 12-10-2005, 01:36 PM
  3. Two's Complement
    By Unregistered in forum C Programming
    Replies: 9
    Last Post: 02-26-2002, 04:52 AM
  4. Question regarding 8/16-bits 2's complement numbers
    By mobius in forum C Programming
    Replies: 1
    Last Post: 09-02-2001, 11:49 PM

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