Solved

Bit handling

Posted on 1998-07-21
2
189 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
Comment Utility
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
Comment Utility
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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. …
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 how to clear a vector as well as how to detect empty vectors in C++.

744 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now