Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!IRO.UMontreal.CA!pinard From: pinard@IRO.UMontreal.CA (Francois Pinard) Newsgroups: comp.lang.c Subject: Better way to generate a mask? Message-ID: Date: 28 May 91 18:03:59 GMT Sender: news@IRO.UMontreal.CA Distribution: comp Organization: Universite' de Montre'al Lines: 19 I just thought asking to the net. Which of the following is better? And of course, why? ----------------------------------------------------------------------> /* This macro generates a mask of NUMBER one bits, right adjusted. */ #define MASK(number) \ (~(~0 << (number))) ----------------------------------------------------------------------< ----------------------------------------------------------------------> /* This macro generates a mask of NUMBER one bits, right adjusted. */ #define MASK(number) \ ((1 << (number)) - 1) ----------------------------------------------------------------------< -- Franc,ois Pinard ``Vivement GNU!'' pinard@iro.umontreal.ca (514) 588-4656 cp 886 L'Epiphanie (Qc) J0K 1J0 ...!uunet!iros1!pinard