473,385 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Masking

How do I mask a portion of an int that's been constructed from several
data fields? That is, I have an int value that contains several values;
bits 10-15 have something I want to isolate and use. I know I can bit-
shift back and forth, but is there a way to mask out these bits and use
them as an integer value? TIA
Nov 14 '05 #1
1 5221
On Wed, 4 Feb 2004 21:30:01 -0700, mr*******@cox.net (Mike Copeland)
wrote:
How do I mask a portion of an int that's been constructed from several
data fields? That is, I have an int value that contains several values;
bits 10-15 have something I want to isolate and use. I know I can bit-
shift back and forth, but is there a way to mask out these bits and use
them as an integer value? TIA


Use the binary & (bitwise and) operator:

unsigned int bits = 0xabcd;
unsigned int something = (bits >> 10) & 0x3f; // get bits 10-15

(The above assumes the low-order bit is called "bit 0")
-leor
Nov 14 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Piotr | last post by:
Please help me, I can't solve this problem: I have domain: www.main_domain.com/index.php?userid=23&parametr1=2&parametr2=3 (and other site files like...
2
by: Ginchy | last post by:
I have uploaded a small 3 page web using MS Publisher 2003 and after uploading I switched on url masking to cloak the url. I am certain that it worked fine. I simply changed the colour scheme...
6
by: Stefan Kowalski | last post by:
Hi Newsgroup Does anyone here care to share their thoughts/experiences with using masking? I am storing categories of books which libraries stock, so that I might have codes: 015-000-000 =...
1
by: john sutor | last post by:
Is there a way in C# to add masking (for a date format) to a textbox?
0
by: Dana Epp | last post by:
I have a ToolBarButton that when I set it to disabled (button.Enabled = false;) causes a really ugly gray masking effect to take place. This is normal and the intended way of the button, but I...
1
by: Brian Keating EI9FXB | last post by:
Hello there, Does anyone know how to to Bitmap masking in .NET, In c++ i used, CreateCompatibleDC GetBitmap Then on the bitmap and the bitmap mask i called. {SelectBitmap StretchBlt}
1
by: NBB | last post by:
I can't figure this one out. Here's the situation, should be pretty for the pros in here. I have a ListBox that is populated with the DataTextField and DataValueField flags of the DataSet....
3
by: Hai Nguyen | last post by:
Hi All I have a textbox want to mask as phone box. How can I do it? Thanks
9
by: Daniel Smedegaard Buus | last post by:
Hey all :) I was wondering about the $error_types (I particularly notice the 's' suffix when reading the manual) parameter for 'set_error_handler()': Can be used to mask the triggering of the...
2
by: meghla | last post by:
I can not understand how to implement bit masking on a c code?? while working with array it is taking too much time.................. so i need help. i need some suggestion and sample code of C...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.