Solved

Bit handling

Posted on 1998-07-21
2
191 Views
Last Modified: 2010-04-10
I have just learned how to turn bits on and off in c++.  I know that a byte (8 bits) is numbered from 1,2,4,8,16,32,64.  My computer is a 32-bit machine and i was wondering how i was able to access the 64 bit?  In addition, i know that an integer carries 4 bytes on my machine - does this mean that there are four rows that i can turn bits on or off?
0
Comment
Question by:karthy
2 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 1168246
if( byte & 64 ){ cout << "64 bit is set" << endl; }
//a four byte (unsigned) int has 32 bits, 1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,1048576,2097152,4194304,8388608,16777216,33554432,67108864,134217728,268435456,536870912,1073741824,2147483648





0
 
LVL 23

Accepted Solution

by:
chensu earned 50 total points
ID: 1168247
To access 64-bit, use a unsigned char array containing 8 bytes. Some compilers may have extension. Microsoft Visual C++ has a data type __int64.

An integer (int) carries 4 bytes, which means you have 32-bit. Of course, you can consider it as four rows each of which contains 8-bit.
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

809 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