473,397 Members | 1,974 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,397 software developers and data experts.

Help me to work with 10bits data

Dear all,

I have 4 numbers (A[0-3]) stored 10 bits data. the first 8 bits data stored in 1 byte data arrays (B[0-3]). the last 2bits of each A[i] stored sequentially in 1 byte number C (the first two bits of C is the last 2 bits of A[0]). Could you please help me to restore A array from B and C data in C-language?

short A[4]; // unsigned
unsigned char B[4];
unsigned char C;

how to set first 6bits of A[0] to zero? and then set the next 8bits of A[0] following to B[0]; and then set the last 2bits of A[0] to the first 2bits of C

Thank you very much,

kik
Oct 14 '08 #1
2 1208
donbock
2,426 Expert 2GB
I have 4 numbers (A[0-3]) stored 10 bits data. the first 8 bits data stored in 1 byte data arrays (B[0-3]). the last 2bits of each A[i] stored sequentially in 1 byte number C (the first two bits of C is the last 2 bits of A[0]). Could you please help me to restore A array from B and C data in C-language?

short A[4]; // unsigned
unsigned char B[4];
unsigned char C;
In what follows, "cat" refers to a bit-concatenation operation. Have I correctly restated your requirements?
... A[0] = B[0] cat (first two bits of C);
... A[1] = B[1] cat (second two bits of C);
... A[2] = B[2] cat (third two bits of C);
... A[3] = B[3] cat (last two bits of C);
I assume "the first two bits" are the two most-significant bits.

If so, then you have two basic tasks:
1. Extract the proper two bits from C.
2. Perform the bit-concatenation operation.

Do you have any ideas for how to perform these tasks in C/C++?
Oct 14 '08 #2
In what follows, "cat" refers to a bit-concatenation operation. Have I correctly restated your requirements?
... A[0] = B[0] cat (first two bits of C);
... A[1] = B[1] cat (second two bits of C);
... A[2] = B[2] cat (third two bits of C);
... A[3] = B[3] cat (last two bits of C);
I assume "the first two bits" are the two most-significant bits.

If so, then you have two basic tasks:
1. Extract the proper two bits from C.
2. Perform the bit-concatenation operation.

Do you have any ideas for how to perform these tasks in C/C++?
yes, thank you for making my question more clear,
Oct 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Dany | last post by:
Hi I want to code a binary value with 10 bits range. I only find the 8bits and the 16bits range. regards, Dany
9
by: Martin | last post by:
Hello, I'm new with triggers and I can not find any good example on how to do the following: I have two tables WO and PM with the following fields: WO.WONUM, VARCHAR(10) WO.PMNUM,...
8
by: baustin75 | last post by:
Posted: Mon Oct 03, 2005 1:41 pm Post subject: cannot mail() in ie only when debugging in php designer 2005 -------------------------------------------------------------------------------- ...
15
by: DavidS | last post by:
Have Visual Studio.NET installed on MS 2000 Professional OS laptop. No issue ever with web development and SQL connections. Purchased new laptop with XP Professional SP2!!!!!!!! & Visual...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
0
by: hagar | last post by:
Hi all, I have a problem which I can not understand why this is happening! Debugging this I actually see that it grabs first record then when stepping through code to the line rsImportTo.AddNew...
15
by: Jay | last post by:
I have a multi threaded VB.NET application (4 threads) that I use to send text messages to many, many employees via system.timer at a 5 second interval. Basically, I look in a SQL table (queue) to...
6
by: AppleBag | last post by:
I'm having the worst time trying to login to myspace through code. Can someone tell me how to do this? Please try it yourself before replying, only because I have asked this a couple of times in...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.