From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4e9860765413318c X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-08-23 07:13:42 PST Path: archiver1.google.com!newsfeed.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3B850FA6.21711F4@raytheon.com> From: Mark Johnson Reply-To: mark_h_johnson@raytheon.com X-Mailer: Mozilla 4.78 [en] (X11; U; Linux 2.4.6-3.1smp i686) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Hi byte and Lo Byte Question References: <9m0gn6$b6j$1@zeus.orl.lmco.com> <3B843C0C.9A3282B@raytheon.com> <3B844CE7.B6C85990@san.rr.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 23 Aug 2001 09:13:58 -0500 NNTP-Posting-Host: 192.27.48.41 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 998576021 192.27.48.41 (Thu, 23 Aug 2001 09:13:41 CDT) NNTP-Posting-Date: Thu, 23 Aug 2001 09:13:41 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:12328 Date: 2001-08-23T09:13:58-05:00 List-Id: Darren New wrote: > > #define LOBYTE(Value) (Value&0xff) > > #define HIBYTE(Value) (Value >>8) > > Why not (value % 256) and (value / 256)? Or the Ada equivalent? > They work, along with several others. I picked the ones w/ mask & shifts because older compilers tend to generate good code for them [the examples you provide require the compiler to detect division by a power of two and convert...]. [OT] As a side note, there was a pretty interesting discussion on the Linux kernel mailing list about min & max & the new "incompatible" version that requires the data type to do the comparison. Apparently this came from the discovery of several independent definitions of the min & max functions [sigh]. NIH lives on. --Mark