Results 1 to 3 of 3
  1. #1
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Question Bitwise operation syntax not recognized?

    Hello, I'm using Eclipse and I wrote this code:
    Java Code:
    int dataLength = 0;
    		Byte[] length = {wavFile[findData], wavFile[findData+1], wavFile[findData+2],wavFile[findData+3]};
    		for(int i = 0; i < length.length; i++) {
    			dataLength<<8;
    			dataLength = dataLength | length[i];
    		}
    ...and my IDE dose not rocognize the the << operation, giving an error.
    Everywhere I look it says thats how you do a bitwise leftshift on an int.
    Does anyone know why this is not working for me?

    What I am trying to so is suppose I have 4 bytes:
    00110011 00000000 10101010 00001111

    I am trying to create the integer with the bit value
    00110011000000001010101000001111

    Thank You

  2. #2
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Default

    errr I guess i would need a long type if i want 4 bytes but still same problem

  3. #3
    Krooger is offline Member
    Join Date
    Nov 2008
    Posts
    43
    Rep Power
    0

    Default

    Never mind i figured it out, I thought it would work alot like:

    i++;

    but you must use it like this:

    myNum = myNum<<8;

    That was not clear in all the usage examples i saw

Similar Threads

  1. Confusing with bitwise NOT operator
    By Willi in forum New To Java
    Replies: 4
    Last Post: 10-16-2009, 11:06 PM
  2. XOR operation on bytes
    By divyanshu023 in forum New To Java
    Replies: 1
    Last Post: 09-17-2009, 07:11 PM
  3. Bitwise operations with long
    By NewJavaBean in forum New To Java
    Replies: 2
    Last Post: 04-07-2009, 07:37 PM
  4. Using the bitwise operators
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-17-2008, 07:39 PM
  5. Frame close operation
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-21-2007, 08:39 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •