Solved

help ( urgent)

Posted on 1997-04-28
1
193 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

708 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

12 Experts available now in Live!

Get 1:1 Help Now