RE: at2 swap_nibbles
"Oded Arbel" <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Message-ID | <[email protected]> |
Why are you casting to int ? -- Oded Arbel m-Wise mobile solutions [email protected] +972-9-9581711 (116) +972-67-340014 ::.. Reasons to Run Away 8-"When the DM just watched a LOT of horror/monster movies" -----Original Message----- From: Andreas Fink [mailto:[email protected]] Sent: Monday, November 25, 2002 8:05 PM To: Oded Arbel Cc: [email protected] Subject: Re: at2 swap_nibbles On Montag, November 25, 2002, at 06:54 Uhr, Oded Arbel wrote: Yes. will somebody just shoot me where I stand ? will save me lots of trouble ;-) I shoud have said return ( ( byte & 0x0F ) << 4 ) | ( ( byte & 0xF0 ) >> 4 ); I'll fix ? how about this: #define HI_NIBBLE(a) ( (int)a >> 4 & 0x0F) #define LOW_NIBBLE(a) ( (int)a & 0x0F) #define SWAP_NIBBLE(a) (( HI_NIBBLE(a) | (LOW_NIBBLE(a) << 4)) & 0xFF) This would work as a macro and has the advantage that the CPU can run it pretty much native. Andreas Fink Fink Consulting GmbH --------------------------------------------------------------- Tel: +41-61-6666332 Fax: +41-61-6666331 Mobile: +41-79-2457333 Address: Clarastrasse 3, 4058 Basel, Switzerland E-Mail: [email protected] Homepage: http://www.finkconsulting.com --------------------------------------------------------------- ______________________________________________________ Scanned and protected by Inflex and McAfee AntiVirus