Meaningless Drivel is fun!*
The moose likes Java in General and the fly likes bitwise logic .. stuff Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "bitwise logic .. stuff" Watch "bitwise logic .. stuff" New topic
Author

bitwise logic .. stuff

Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22
To all JavaRanch members: thanks for the help.
I have yet another question for you today. I have a class with a method that performs bitwise logic [int add(int a, int b) and int sub(int a, int b)]. Here's an example:

Now say I have a String of 1's and 0's(or an int composed of 1's and 0's, whichever one is more appropriate [?]). I want to process each character with the corresponding character in a second String, equal length. For instance:

I tried a lot of b.add((int)x.charAt(i), (int)y.charAt(i)); using the string method desribed, but I wound up with 97's and 98's. Do you think I should incorporate a loop into the bit class, and change it so it handles Strings? But how do I get to the point where I have an easy-to-work-with Integer = 1/0?
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
It would be better, if u provide ur "bit" class and important methods in it... I think the problem is inside ur add method... Let's solve it...


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Robbie Harjes
Greenhorn

Joined: Nov 09, 2003
Posts: 22

Sorry for the late reply
 
 
subject: bitwise logic .. stuff