This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: right shift : strange behavior


2007/7/27, Manish Baphna <manish_baphna@yahoo.com>:
> int number ;
>
> number = ( 0xFFFFFFFF >> 5 ) ;
> cout << hex << number << endl ;
>
> number = ( ~0x0 >> 5 ) ;
> cout << hex << number << endl ;
> --------
> output >> 7ffffff
>          ffffffff
>
> Does that imply that '~' will always return a signed
> value and hence this behavior ?
Yes. '~' will return a signed number which can be printed as '-1'.
0xFFFFFFFF >> 5 depends on implementation. Because types of left and
right operands are both floating-point number, gcc will parse them as
unsigned integer.

Hope to be helpful :)

> Thanx in Advance :)
> -Manish
>
>
>
> ____________________________________________________________________________________
> Sick sense of humor? Visit Yahoo! TV's
> Comedy with an Edge to see what's on, when.
> http://tv.yahoo.com/collections/222
>


-- 
        Best wishes!
Yours,
Lijuan Hai
  _  _
  (_)(_)
   (,,)
  =()=
 ((__)\
   _|L\_______/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]