Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 08 Sep 2012 09:00:07 -0500 Message-ID: <504B4F68.1AE6@mindspring.com> Date: Sat, 08 Sep 2012 10:00:08 -0400 From: pete Reply-To: pfiland@mindspring.com Organization: PF X-Mailer: Mozilla 3.04Gold (WinNT; I) MIME-Version: 1.0 Newsgroups: comp.lang.c Subject: Re: #define BYTES *8 References: <4f46c814-7397-40f9-8c60-c24578e2eec1@googlegroups.com> <504946AB.4E34@mindspring.com> <25f81237-76fd-4d1b-90d4-671aa32ffdc6@googlegroups.com> Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Lines: 24 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.223.191 X-Trace: sv3-j6dSGlUB/fRgg61wW7PT4AtKvoY4f823HrcJ3SfeFt2CFRDcYxY68L1djfx09Zn3EpkAW4eg0coA7qw!VQ3vr4NnQS6pIs2nEuKMTG/3BtO95GmhT7qaej7drQqwCxZZht6wAT5KBbz0D0yzuJiddODOk9fS!nLhlfu5Cm1Y= X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 1917 Xref: csiph.com comp.lang.c:26140 Öö Tiib wrote: > > On Friday, September 7, 2012 3:58:20 AM UTC+3, pete wrote: > > John Bode wrote: > > > If you need to do conversions from one unit to another, > > > create a function or function-like macro with a name > > > that *clearly* conveys the nature of the conversion: > > > > > > #define TO_BITS(x) ( sizeof (x) * CHAR_BIT ) > > > #define TO_BYTES(x) ( (x) / CHAR_BIT ) > > > > I might be inclined to go a little further. > > > > #define BYTES_TO_BITS(x) ( sizeof (x) * CHAR_BIT ) > > It is misleading name, should be something like: > > #define SIZE_IN_BITS_OF(x) ( sizeof(x) * CHAR_BIT ) Either that or I should have read the definition first. I was thinking of it as though it had been ( (x) * CHAR_BIT ) -- pete