🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #10728

Re: Inversion de bits

#10728
From: Fco. Javier Espejo
Date: Fri, 08 Feb 2002 02:45
35 lines
2163 bytes
>     * hay otro fallo: en realidad deberia ser mas o menos asi:
>
>     for(i=0,d=0,cc=c;i<8*sizeof(unsigned char)-1;i++)
>     {
>         d |= cc&0x01;
>         cc = cc >> 1;
>         d = d << 1;
>     }
>     d |= cc&0x01;

Pues tienes toda la raz�n, pero podias haber corregido el error m�s
f�cilmente, y si me aceptas un consejo de buen rollo pon nombres m�s
clarificadores. El segundo ejemplo me ha dejado as� :-o

void invertir(unsigned char *byte)
{
   unsigned char temp=0,i,bit;
   for(i=0;i<sizeof(unsigned char)*8;i++)
  {
      bit=*byte&0x01; /* El error era el desplazamiento ->
bit=(*byte>>1)&0x01;*/
      *byte=*byte>>1;
      temp=(temp<<1)|bit; /* Recordemos que la primera vez temp==0 */
  }
  *byte=temp;
}

NOTA: Sigo sin probar el c�digo, <mi reino por un compilador>. Por lo tanto
puede seguir teniendo errores, pero la idea creo que est� cogida.

---------------------------------
jespejoYASABES@QUEHACERarrakis.es
�Sistemas Operativos? �Vis�tala!
http://www.arrakis.es/~jespejo
---------------------------------
Technical Details
Message-ID: <3c633b95$1_1@news.arrakis.es>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!caladan.arrakis.es
References: <3C61171A.5F9E4911@eq.upc.es> <3c61c2a4$1_4@news.arrakis.es> <3c61d85d_4@news.arrakis.es> <a3u1uu$912$1@news.unizar.es>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,bd33173853cfd14f
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-02-07 18:44:58 PST
From: "Fco. Javier Espejo" <jespejoYASABES@QUEHACERarrakis.es>
Newsgroups: es.comp.os.linux.programacion
References: <3C61171A.5F9E4911@eq.upc.es> <3c61c2a4$1_4@news.arrakis.es> <3c61d85d_4@news.arrakis.es> <a3u1uu$912$1@news.unizar.es>
Subject: Re: Inversion de bits
Date: Fri, 8 Feb 2002 03:45:31 +0100
Lines: 37
Organization: http://www.arrakis.es/~jespejo
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 212.59.223.207
Message-ID: <3c633b95$1_1@news.arrakis.es>
X-Trace: caladan.arrakis.es 1013136277 212.59.223.207 (8 Feb 2002 03:44:37 +0100)
X-Original-NNTP-Posting-Host: 195.5.65.34
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!out.nntp.be!propagator-SanJose!in.nntp.be!caladan.arrakis.es