🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Como acceder al bit x de un dato

#9511
From: Ivn Snchez Ortega MR
Date: Mon, 17 Jun 2002 17:12
26 lines
1669 bytes
"Angel" <...
> Suponiendo q tenemos un dato de n bytes, com podria acceder al bit x??
> en C o C++.
>
> ej:
>
> bool cual_es_el_valor_del_bit(n_bit);


function bit_a_1(n, dato)  // el bit n-�simo del dato, tomando 0=bit m�s a
la izquierda
{
return (dato & 1>>n);
}

(mueves un 1 a la derecha tantos bits como necesites, y lo aplicas como
m�scara al dato, con el &, que te devolver� 0 o algo distinto de 0)


--
----------------------
Iv�n S�nchez Ortega
ivansanchez@wanadoo.es

"Un ordenador no es una televisi�n ni un microondas, es una herramienta
compleja."
Technical Details
Message-ID: <ael5an$kj3$1@reader2.wnet>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.251.151.101!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!not-for-mail
References: <aekvlb$81hpu$1@ID-148170.news.dfncis.de>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,8245fc4b08721416
X-Google-Attributes: gidf86c8,public
X-Google-ArrivalTime: 2002-06-17 10:16:23 PST
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news.tele.dk!small.news.tele.dk!193.251.151.101!opentransit.net!newsfeed.comtenidos.com!newsfeeder.wanadoo.es!not-for-mail
From: "Iv�n S�nchez Ortega \"MR\"" <(eme)(erre)(punto)@wanadoo.(e)(ese)>
Newsgroups: es.comp.os.linux.programacion
Subject: Re: Como acceder al bit x de un dato
Date: Mon, 17 Jun 2002 19:12:37 +0200
Organization: Wanadoo
Lines: 28
Message-ID: <ael5an$kj3$1@reader2.wnet>
References: <aekvlb$81hpu$1@ID-148170.news.dfncis.de>
NNTP-Posting-Host: 62-36-138-49.dialup.uni2.es
X-Trace: reader2.wnet 1024333976 21091 62.36.138.49 (17 Jun 2002 17:12:56 GMT)
X-Complaints-To: usenet@wanadoo.es
NNTP-Posting-Date: Mon, 17 Jun 2002 17:12:56 +0000 (UTC)
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200