Solved

Bit handling

Posted on 1998-07-21
2
193 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

733 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