[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [linux] [OT] Manipuler un bit en c



Je voudrais savoir comment on peut manipuler un bit particulier d'un octet en c
Par ex. :
int test=0;

Pour positionner un bit (p.ex. le bit 3):
- à 1:   test =| (1<<3);
- à 0:   test =& ~(1<<3);

Tout en sachant que l'ordre des bits est:

76543210

Le 3ème bit de poids faible serait donc le "2".

--
  -o) Pascal Bleser   ATOS Origin/Aachen(DE) |
  /\\         <pascal.bleser@atosorigin.com> |
 _\_v <guru@linuxbe.org>                     |
---------------------------------------------|
Jesus saves,Buddha makes incremental backups :
---------------------------------------------'

_______________________________________________
Linux Mailing List
Archives: http://unixtech.be/mailman/listinfo/linux