Java bitwise operation

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Nov 2009
Posts: 2
Reputation: rameshnerella is an unknown quantity at this point 
Solved Threads: 0
rameshnerella rameshnerella is offline Offline
Newbie Poster

Java bitwise operation

 
0
  #1
29 Days Ago
i am new to this kind of programming. please help me,.

i got an IP address (32bits) & 3 int (32 X 3 = 96bits) totaling for 128bits i.e., 16bytes.

my problem here is, how to club them all together to create a 16byte string.

please help. thanks in advance
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: eggmatters is an unknown quantity at this point 
Solved Threads: 4
eggmatters eggmatters is offline Offline
Junior Poster in Training
 
0
  #2
29 Days Ago
cast your IP address as a string if it isn't already. Cast your ints as Int objects, then you'll just need to concatenate them:
  1. Integer one = integerone //your initial value;
  2. Integer two = integertwo
  3. Integer three = integerthree
  4. String myChunk = ipstring.concat(all of your Ints to strings);
Is that what you are asking?
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 2
Reputation: rameshnerella is an unknown quantity at this point 
Solved Threads: 0
rameshnerella rameshnerella is offline Offline
Newbie Poster
 
0
  #3
29 Days Ago
hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 63
Reputation: eggmatters is an unknown quantity at this point 
Solved Threads: 4
eggmatters eggmatters is offline Offline
Junior Poster in Training
 
0
  #4
29 Days Ago
Originally Posted by rameshnerella View Post
hi eggmatters, thanks for your reply.

but that is not what i am looking for..

this involves some kind of biwise operation.

everything together should become a 16byte string.
Ok, you've lost me there. you are creating strings. Strings are arrays of characters. Characters are bits. Ultimately, anything you code is a 'bitwise' operation. The term 'bitwise operation' explicitly means a comparison of two strings of bytes. Namely XOR and XAND.
Could you be more specific about how your data is typed? is it all character arrays? is it that you need to convert your ints to bytes? Do you want to convert all of your data into a hexidecimal string? Do you have sample code or some type of data structure that you can provide?
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 1,595
Reputation: BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all BestJewSinceJC is a name known to all 
Solved Threads: 201
BestJewSinceJC BestJewSinceJC is offline Offline
Posting Virtuoso
 
0
  #5
29 Days Ago
By bit operation I think he literally means an operation that directly operates on/manipulates bits. Although the only way I see to do this is to set aside an array of that many bits (via creating an array of 4 integers, which are 32 bits each in Java), then by using some specific operation such as OR (where each int in the array was initialized to 0). Probably not the solution he wants though.
Out.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 4
Reputation: mruthyunjaya is an unknown quantity at this point 
Solved Threads: 0
mruthyunjaya mruthyunjaya is offline Offline
Newbie Poster
 
0
  #6
28 Days Ago
i think the issue here is how to create a 16byte string.

  1. String testString = "quickbrownfoxjum";

this forms a 16byte string.
he is trying to club 32bit ip number & other 3 integers together a string like the above said.

16 letters in the string should represent all the 4 values.

i think, this is what he is looking for....
Reply With Quote Quick reply to this message  
Reply

Tags
java

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC