Pages: [1]   Go Down
Author Topic: problem with bitshifting  (Read 301 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

hy, i wanna do a simple bitshifting.
heres my code:



    case 4:
      int zw1 = gameData1 >> 1;
      int zw2 = gameData2 >> 1;
      gameData1 = zw1;
      gameData2 = zw2;

      break;



but it doesnt work. yes, it enters this case, i checked that.


anyone an idea, why this does not work?

in 17 hours is my presentation of my diploma project. so if anyone got a suggestion, i'll be happy for it. smiley-wink
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 11
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You can just do:

gameData1 >>= 1;

But what's not working?  What data type is gameData1?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 24
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

int gameData1 = 255;



just simple.
Logged

Las Vegas, NV
Offline Offline
God Member
*****
Karma: 0
Posts: 507
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What you posted looks fine.  I suspect the problem is in part of the code you haven't posted yet.

- Ben
Logged


Pages: [1]   Go Up
Jump to: