This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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

bitwise logic .. stuff

Robbie Harjes

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
Robbie Harjes

Joined: Nov 09, 2003
Posts: 22

Sorry for the late reply
Have you checked out Aspose?
subject: bitwise logic .. stuff
It's not a secret anymore!