Re: More bit shifting issues
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Tue, 01 Apr 2008 16:58:56 -0500
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
.
- References:
- More bit shifting issues
- From: Boltar
- More bit shifting issues
- Prev by Date: Re: Strange bit shifting result with gcc - am I missing something obvious?
- Next by Date: fgets() and fopen() with "w"
- Previous by thread: Re: More bit shifting issues
- Next by thread: Re: MISRA-C:2010 (version 3)
- Index(es):
Relevant Pages
|