| www.delorie.com/archives/browse.cgi | search |
| From: | "Rafał Maj" <r_maj AT poczta DOT onet DOT pl> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Odp: twin complement ...... |
| Date: | Fri, 18 Aug 2000 01:08:22 +0200 |
| Organization: | Academic Computer Center CYFRONET AGH |
| Lines: | 30 |
| Message-ID: | <8nhr5q$hs8$1@info.cyf-kr.edu.pl> |
| 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> |
| NNTP-Posting-Host: | d-94-53-08.cyfronet.krakow.pl |
| X-Trace: | info.cyf-kr.edu.pl 966553594 18312 149.156.1.168 (17 Aug 2000 23:06:34 GMT) |
| X-Complaints-To: | news AT cyf-kr DOT edu DOT pl |
| NNTP-Posting-Date: | 17 Aug 2000 23:06:34 GMT |
| X-Priority: | 3 |
| X-MSMail-Priority: | Normal |
| X-Newsreader: | Microsoft Outlook Express 5.00.2615.200 |
| X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2615.200 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Florent <florent AT oih DOT rwth-aachen DOT de> wrote :
> What do you think about this function, I tried it with some values and it
> seems to work.
>
> long int TwinComplement(long int Value) {
>
> long int Temp;
> Temp=Value;
> Value=(~Value)+1;
> if (Temp<=0xf) Value=Value&0x0000000f;
> if (Temp<=0xff) Value=Value&0x000000ff;
> if (Temp<=0xfff) Value=Value&0x00000fff;
> if (Temp<=0xffff) Value=Value&0x0000ffff;
> if (Temp<=0xfffff) Value=Value&0x000fffff;
> if (Temp<=0xffffff) Value=Value&0x00ffffff;
> if (Temp<=0xfffffff) Value=Value&0x0fffffff;
>
> return Value;
> }
>
1) This function will work quit slow (if you're going to use it in some loop
for example)
2) Can you tell me what exacly is twin complement ? How this function is
suppose to work ?
Rafal
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |