Semantics of bit inversion operator

This is a discussion on Semantics of bit inversion operator within the C++ Programming forums, part of the General Programming Boards category; Hi, what is the return type of the operator~ for integral types? I thought no promotion needs to be done ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    1

    Question Semantics of bit inversion operator

    Hi,

    what is the return type of the operator~ for integral types? I thought no promotion needs to be done here, but from a question to the gcc-help mailing list I got the following explanations:
    The problem is that the operator "~" when applied upon the unsigned
    char returns always a signed char.
    and
    Integral promotions are performed for operator ~ and int can represent
    all the values of unsigned char, so the operand is promoted to int.
    So my questions are
    1. what are the promotion rules for bit inversion regarding integral types?
    2. is this behaviour implementation defined?


    bye,
    deVas

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,448
    Quote Originally Posted by deVas
    what are the promotion rules for bit inversion regarding integral types?
    Integral promotion is performed.

    Quote Originally Posted by deVas
    is this behaviour implementation defined?
    No, though of course the details of the integral promotion itself is implementation defined.
    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

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. overloaded >> operator issue...
    By soulredemption in forum C++ Programming
    Replies: 2
    Last Post: 10-17-2005, 10:53 PM
  2. porting application from 32 bit to 64 bit error
    By gandalf_bar in forum Linux Programming
    Replies: 1
    Last Post: 09-14-2005, 09:20 AM
  3. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 12:55 PM
  4. Bit processing in C
    By eliomancini in forum C Programming
    Replies: 8
    Last Post: 06-07-2005, 10:54 AM
  5. Porting from 32 bit machine to 64 bit machine!
    By anoopks in forum C Programming
    Replies: 10
    Last Post: 02-25-2005, 07:02 PM

Tags for this Thread


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