This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: right shift : strange behavior
- From: "Lijuan Hai" <hailijuan at gmail dot com>
- To: "Manish Baphna" <manish_baphna at yahoo dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Fri, 27 Jul 2007 15:38:25 +0800
- Subject: Re: right shift : strange behavior
- References: <514500.24300.qm@web38907.mail.mud.yahoo.com>
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\_______/