Solved

help ( urgent)

Posted on 1997-04-28
1
225 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
[X]
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
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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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.

751 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