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: Thu, 06 Sep 2012 19:58:18 -0500 Message-ID: <504946AB.4E34@mindspring.com> Date: Thu, 06 Sep 2012 20:58:19 -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> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Lines: 16 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 4.154.217.228 X-Trace: sv3-Irw2mjKIt0i682EHFGJ8K5jeLwpr8rSV7JyTAVN+Zz0C5yAkoTSNv1i5JGv1d4+HG9CGU+t+6yBjWfc!fy4VIln2L6qzaM317D7vLHoTsv59VU7au8IyYMwvtXmbdisQI9/QiCKPOLIRIJqiBQOjdTC40GIY!mQ3lm3Eusl8= 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: 1513 Xref: csiph.com comp.lang.c:26024 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 ) #define BITS_TO_BYTES(x) ( (x) / CHAR_BIT ) -- pete