• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

bitwise logic .. stuff

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Robbie Harjes
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sorry for the late reply
 
That is a really big piece of pie for such a tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic