Coding this bitwise computation...

  • Thread starter Thread starter Michael A. Covington
  • Start date Start date
M

Michael A. Covington

I'm assembling text attribute bytes (upper and lower nybbles) and have the
following line of code:

ushort a = (ushort)((csbi.wAttributes & (ushort)0x0F) |
(ushort)((ushort)value<<4));



Here value is an enum of base type ushort, csbi.wAttributes is a ushort...
so why is everything coverting to int (not even uint) and having to be
converted back?



There has to be a better way to code this!
 
On Wed, 10 Mar 2004 23:34:29 -0500, Michael A. Covington

-- snip --
so why is everything coverting to int (not even uint) and having to be
converted back?
Because int is the smallest type .Net will do calculations on. Possibly
due to speed issues and the use of 32 bit processors.

-- snip --
 
OK, I'll render them all into int (not even uint), do the computation, and
convert to ushort at the end. Thanks to all.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top