Solved

help ( urgent)

Posted on 1997-04-28
1
205 Views
Last Modified: 2012-05-04
I have written the following program that allows the user to enter a set of numbers and then store them in an array.

My next step is to take each number and perform some shift operation on it.

My first question is :
How can I store the number in a 16 bit word length inside the computer.

Second question :
If for example the first element in the array is 6 which is 0000000000000110 in binary ( 16 bit word length ), how can I  mask it so that I can store bits 3 to 6 as a number "in this case it is 0".


Cheers.
0
Comment
Question by:a9628657
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1163019
1. How can I store the number in a 16 bit word length inside the computer.?

You can use the data type: unsigned short.
unsigned short nNumArray[20];


2. If for example the first element in the array is 6 which is 0000000000000110 in binary ( 16 bit word length ), how can I mask it so that I can store bits 3 to 6 as a number "in this case it is 0".

unsigned short nMaskedResult = nNumArray[0] & 0x0078;
unsigned short nShiftedResult = nMaskedResult >> 3;


0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now