Re: right shift : strange behavior

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007/7/27, Manish Baphna <manish_baphna@xxxxxxxxx>:
> 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 of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux