Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

help ( urgent)

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

789 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