?
Solved

Bit handling

Posted on 1998-07-21
2
Medium Priority
?
195 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
[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
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 200 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

765 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