Re: More bit shifting issues



Boltar wrote:

I seem to be having yet more wierd issue with bit shifting. It
seems the following code doesnt do anything under gcc (ie it
returns -1 as both results). Anyone know why? Is it another
language definition or CPU issue?

main() {
printf("%d\n",(int)0xFFFFFFFF >> 1);
printf("%d\n",(int)-1 >> 1);
}

I suspect this covers it:

6.5 Expressions

.... snip ...

[#4] Some operators (the unary operator ~, and the binary
operators <<, >>, &, ^, and |, collectively described as
bitwise operators) are required to have operands that have
integer type. These operators return values that depend on
the internal representations of integers, and have
implementation-defined and undefined aspects for signed
types.

--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.



--
Posted via a free Usenet account from http://www.teranews.com

.



Relevant Pages

  • Re: More bit shifting issues
    ... I seem to be having yet more wierd issue with bit shifting. ... the following code doesnt do anything under gcc (ie it returns -1 as ... to get one of arithmetic right shift or logical right shift. ...
    (comp.lang.c)
  • More bit shifting issues
    ... I seem to be having yet more wierd issue with bit shifting. ... the following code doesnt do anything under gcc (ie it returns -1 as ... CPU issue? ...
    (comp.lang.c)
  • Re: WinAVR warum hier kein Warning?
    ... Parameter "-Wall" im gcc gesetzt habe? ... Keine Ahnung, nutze den GCC nicht. ... Allerdings sind Warnungen ja auch nur ... When a value with integer type is converted to another ...
    (de.sci.electronics)
  • Re: How to store a 13 digit number in c ?
    ... maximums for the number of bits in each integer type. ... which C99 compiler do "almost" everybody use these days? ... said something about GCC not having changed in 3 years. ...
    (comp.lang.c)
  • Re: Visual Studio 2005 x64 mode.
    ... just like in GCC. ... What again are you complaining about? ... order to get 64-bit integer type one should use `long long' type: ... "Data Type Ranges" ...
    (microsoft.public.vc.language)