Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c > #18421

Re: difference between ~0U and ~0

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail
NNTP-Posting-Date Fri, 09 Mar 2012 17:52:08 -0600
Message-ID <4F5A97A8.7D9B@mindspring.com> (permalink)
Date Fri, 09 Mar 2012 18:52:08 -0500
From pete <pfiland@mindspring.com>
Reply-To pfiland@mindspring.com
Organization PF
X-Mailer Mozilla 3.04Gold (WinNT; I)
MIME-Version 1.0
Newsgroups comp.lang.c
Subject Re: difference between ~0U and ~0
References <6ee3baa7-5370-4fb6-acfe-262f2bc6036e@sc10g2000pbc.googlegroups.com> <4F58BA48.527D@mindspring.com> <24006453.364.1331218377093.JavaMail.geo-discussion-forums@vbcu2> <4F5A8A03.3657@mindspring.com> <kfn1up1pdxj.fsf@x-alumni2.alumni.caltech.edu>
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
Lines 44
X-Usenet-Provider http://www.giganews.com
NNTP-Posting-Host 4.154.221.196
X-Trace sv3-yXMOC+oEoGVNWw7Mp6G+BmgJUkoZhyZ6gF/oogkgHuCOUEOVYNNnGBBNHxyz4EPn2NtMPoCdhMB54YG!s7ew3lGFSYhznYePg6sUNM38qSpzM4KgJ3MW8jcZGGki/5FJz38b8yDZz2HXV2T9I07/LbypMvrk!sYtkSo93FsY=
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 2375
Xref csiph.com comp.lang.c:18421

Show key headers only | View raw


Tim Rentsch wrote:
> 
> pete <pfiland@mindspring.com> writes:
> 
> > James Piper wrote:
> >>
> >> On Thursday, March 8, 2012 8:55:20 AM UTC-5, pete wrote:
> >> > somenath wrote:
> >> >
> >> > > According to my understanding ~0 is -1.
> >> > > So I will get all bit 1 as a
> >> > > result of ~0 in 2's complement system.
> >> >
> >> > Close, but backwards.
> >> >
> >> >     ~0 is all bit 1.
> >> >
> >> >     So you will get -1 as a
> >> >     result of ~0 in 2's complement system.
> >> That's true.
> >>
> >> 1 in 8-bit format is: 0000 0001
> >> To get neg- 1:
> >> 1. Negate bits. 1111 1110
> >> 2. Add 1: 1111 11111
> >>
> >> Same results regardless of the bit size.
> >
> > Another way for negatising in two's complement is:
> > 1. subtract 1. 0000 0000
> > 2. Negate bits: 1111 11111
> >
> > I've worked on assembly code
> > that had it done either way in different parts of the code.
> > I don't know if it was done by the same person.
> 
> The first method turns x into -x;  the second turns -x into x.

I'm not going to dignify that with a response.

Wait, I told that wrong ...

-- 
pete

Back to comp.lang.c | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

difference between ~0U and ~0 somenath <pal_somenath@emc.com> - 2012-03-03 20:03 -0800
  Re: difference between ~0U and ~0 Stephen Sprunk <stephen@sprunk.org> - 2012-03-03 22:55 -0600
  Re: difference between ~0U and ~0 BGB <cr88192@hotmail.com> - 2012-03-03 23:01 -0700
  Re: difference between ~0U and ~0 Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-03-04 12:50 +0000
  Re: difference between ~0U and ~0 pete <pfiland@mindspring.com> - 2012-03-08 08:55 -0500
    Re: difference between ~0U and ~0 James Piper <usenet@jamespiper.com> - 2012-03-08 06:52 -0800
      Re: difference between ~0U and ~0 pete <pfiland@mindspring.com> - 2012-03-09 17:53 -0500
        Re: difference between ~0U and ~0 Tim Rentsch <txr@alumni.caltech.edu> - 2012-03-09 15:11 -0800
          Re: difference between ~0U and ~0 pete <pfiland@mindspring.com> - 2012-03-09 18:52 -0500

csiph-web