Re: shame on MISRA
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Sat, 28 Apr 2007 10:15:42 -0400
Dan Henry wrote:
CBFalconer <cbfalconer@xxxxxxxxx> wrote:
Dan Henry wrote:
CBFalconer <cbfalconer@xxxxxxxxx> wrote:
Dan Henry wrote:
CBFalconer <cbfalconer@xxxxxxxxx> wrote:... snip ...
~ 0 ---> ~0x0000 ---> 0xffff "Wrong. C representation may be sign/magnitude or 1's complement.
2's comp: -1 ---> -0x0001 ---> 0xffff
~ 1 ---> ~0x0001 ---> 0xffff (note NOT sign)
~ 0 ---> ~0x0000 ---> 0xffff "1's comp: -1 ---> -0x0001 ---> 0xffff
~ 1 ---> ~0x0001 ---> 0xfffe (note NOT sign)
or ~ 0 ---> ~0xffff ---> 0x0000 "
~ 0 ---> ~0x0000 ---> 0xffff "sign mag: -1 ---> -0x0001 ---> 0xffff
~ 1 ---> ~0x0001 ---> 0xfffe (note NOT sign)
because of the rules for bringing unsigned into range.
~1? I read Marcin to be asking whether ~0 won't set all 1s.
See the additions above. Only -1 always returns 0xffff.
Isn't the integer constant 0 (lacking the unary - operator) in a
1's complement system positive zero, not negative zero? Doesn't
your second ~0 example actually represent ~-0?
In 1's complement -0 is equal to +0.
Right, but I am wondering about the predictability of the
underlying bit patterns.
Are you saying that in 1's complement the integer constant 0 could
have the bit pattern for +0 (all 0's) *or* the bit pattern for -0
(all 1's) and that using the unary - operator on the integer
constant 0 can yield either all 1's or all 0's -- that my
memset(&object, 0, sizeof object) is equally likely to zero all
bits as set all bits of the memory that object occupies?
Exactly.
--
<http://www.cs.auckland.ac.nz/~pgut001/pubs/vista_cost.txt>
<http://www.securityfocus.com/columnists/423>
<http://www.aaxnet.com/editor/edit043.html>
<http://kadaitcha.cx/vista/dogsbreakfast/index.html>
cbfalconer at maineline dot net
--
Posted via a free Usenet account from http://www.teranews.com
.
- References:
- Re: shame on MISRA
- From: Arlet
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- From: Robert Adsett
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- From: CBFalconer
- Re: shame on MISRA
- From: Marcin Wolcendorf
- Re: shame on MISRA
- From: CBFalconer
- Re: shame on MISRA
- From: Dan Henry
- Re: shame on MISRA
- From: CBFalconer
- Re: shame on MISRA
- From: Dan Henry
- Re: shame on MISRA
- From: CBFalconer
- Re: shame on MISRA
- From: Dan Henry
- Re: shame on MISRA
- Prev by Date: Re: Warning -- Off Topic, Job Ad
- Next by Date: Help to design a loader & CD-ROM emmulator in C
- Previous by thread: Re: shame on MISRA
- Next by thread: Re: shame on MISRA
- Index(es):
Relevant Pages
|