delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/05/12/13:18:22

Message-ID: <391C4528.6AFBB741@earthlink.net>
From: Martin Ambuhl <mambuhl AT earthlink DOT net>
Organization: Nocturnal Aviation
X-Mailer: Mozilla 4.73 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Right shift
References: <391C0409 DOT 79567772 AT tiscalinet DOT it>
Lines: 34
Date: Fri, 12 May 2000 17:52:41 GMT
NNTP-Posting-Host: 63.23.133.137
X-Complaints-To: abuse AT earthlink DOT net
X-Trace: newsread2.prod.itd.earthlink.net 958153961 63.23.133.137 (Fri, 12 May 2000 10:52:41 PDT)
NNTP-Posting-Date: Fri, 12 May 2000 10:52:41 PDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com


night DOT walker AT tiscalinet DOT it wrote:
> 
> Why right-shifting ">>" a negative signed int will first turn it
> positive?
> 
> 4 >>1 = 2 but also -4 >> 1 = 2!!

I don't believe you:

#include <stdio.h>

int main(void)
{
     printf("(4 >> 1) == %d\n(-4 >> 1) == %d\n", 4 >> 1, -4 >> 1);
     return 0;
}

(4 >> 1) == 2
(-4 >> 1) == -2

Now show us your code.

-- 
Martin Ambuhl	mambuhl AT earthlink DOT net

What one knows is, in youth, of little moment; they know enough who
know how to learn. - Henry Adams

A thick skin is a gift from God. - Konrad Adenauer
__________________________________________________________
Fight spam now!
Get your free anti-spam service: http://www.brightmail.com

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019