delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/08/18/05:15:37

From: "Florent" <florent AT oih DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: twin complement ......
Date: Fri, 18 Aug 2000 11:07:58 +0200
Organization: Aachen University of Technology (RWTH)
Lines: 29
Message-ID: <8niubs$8kv$1@nets3.rz.RWTH-Aachen.DE>
References: <8ngqu9$fl8$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <8nhg65$ogi$1 AT nets3 DOT rz DOT RWTH-Aachen DOT DE> <8nhr5q$hs8$1 AT info DOT cyf-kr DOT edu DOT pl>
NNTP-Posting-Host: pupulse.oih.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 966589628 8863 137.226.149.42 (18 Aug 2000 09:07:08 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 18 Aug 2000 09:07:08 GMT
X-Newsreader: Microsoft Outlook Express 4.72.3110.5
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

>1) This function will work quit slow (if you're going to use it in some
loop
>for example)

ah, why ? because of all tests ?
no it's not in a loop, I use it three times when I receive some special
datas from the machine.

>2) Can you tell me what exacly is twin complement ? How this function is
>suppose to work ?


a twin complement is :
int x=0x10
in bin x= 0001 0000
wiht the first complement we get 1110 1111 (replace all 1 by 0 et 0 by1)
the n with the 2nd complement we had 1
1110 1111
+               1
_________

1111 0000

so the twin complement of 0x10 is 0xf0
usually it's used for the negative number, but here I received some datas
from a machine and I need to do the twin complement to read the value.



- Raw text -


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