Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > C++ Moderated > Re: Hexadecimal...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 11 Topic 9522 of 9828
Post > Topic >>

Re: Hexadecimal and bitwise operations

by MiB <Michael.Boehnisch@[EMAIL PROTECTED] > Apr 20, 2008 at 09:02 PM

On 21 Apr., 00:13, "Hak...@[EMAIL PROTECTED]
" <Hak...@[EMAIL PROTECTED]
> wrote:
> I know you guys might not need the commenting, but I consider that
> part of the function so...

You bet :-)))

unsigned int getHexDigit( unsigned int hex, unsigned short
digitWanted )
{
     return ( hex >> ( ( digitWanted - 1 ) << 2 ) ) & 0xf;
}

This version is simpler... just ****fts the wanted digit to the 1's
place and masks out the rest.
Note x << 2 is the same as x * 4. I put extra braces to make clear on
the processing order.

best,

    Michael.

-- 
      [ See http://www.gotw.ca/resources/clcm.htm
for info about ]
      [ comp.lang.c++.moderated.    First time posters: Do this! ]
 




 11 Posts in Topic:
Hexadecimal and bitwise operations
"Hakusa@[EMAIL PROTE  2008-04-19 02:01:53 
Re: Hexadecimal and bitwise operations
Alberto Ganesh Barbati &l  2008-04-19 18:09:27 
Re: Hexadecimal and bitwise operations
Pavel Minaev <int19h@[  2008-04-19 18:13:49 
Re: Hexadecimal and bitwise operations
=?UTF-8?B?QmrDtnJu?= Hend  2008-04-19 18:14:09 
Re: Hexadecimal and bitwise operations
Goedson Paixao <goedso  2008-04-19 18:14:55 
Re: Hexadecimal and bitwise operations
Brendan <catphive@[EMA  2008-04-19 18:13:28 
Re: Hexadecimal and bitwise operations
"Ivan Vecerina"  2008-04-19 18:17:19 
Re: Hexadecimal and bitwise operations
Michael.Boehnisch@[EMAIL   2008-04-19 18:15:12 
Re: Hexadecimal and bitwise operations
"Hakusa@[EMAIL PROTE  2008-04-20 16:13:16 
Re: Hexadecimal and bitwise operations
MiB <Michael.Boehnisch  2008-04-20 21:02:20 
Re: Hexadecimal and bitwise operations
Jonathan Thornburg <cl  2008-04-25 03:46:08 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu Jul 24 15:47:26 CDT 2008.