P
Philipp
Hello
On http://cplus.about.com/od/advancedtutorials/l/aa042203h.htm
I found an example of bitshifting (see below).
Q: Is the bitshifting dependant on platform specific things (like how
the number is represented in memory) or can one count on the usual
behaviour (eg "<< 1" multiplies by 2) on any platform?
Thanks Phil
-- code found on web site --
#include <iostream>
using namespace std;
int main()
{
unsigned short bvec = 1024;
for (int i = 0; i < 15; i++) {
cout << bvec << endl;
bvec = bvec >> 1;
}
return 0;
}
----
Results:
1024
512
256
128
64
32
16
8
4
2
1
0
0
0
0
On http://cplus.about.com/od/advancedtutorials/l/aa042203h.htm
I found an example of bitshifting (see below).
Q: Is the bitshifting dependant on platform specific things (like how
the number is represented in memory) or can one count on the usual
behaviour (eg "<< 1" multiplies by 2) on any platform?
Thanks Phil
-- code found on web site --
#include <iostream>
using namespace std;
int main()
{
unsigned short bvec = 1024;
for (int i = 0; i < 15; i++) {
cout << bvec << endl;
bvec = bvec >> 1;
}
return 0;
}
----
Results:
1024
512
256
128
64
32
16
8
4
2
1
0
0
0
0