• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

java

 
Sreeram Rajesh
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to add two numbers without using addition operator.i have tried my hand in solving the problem by using bitwise operators.but the solution worked for few numbers and when i tried the same code for different input i failed to achieve the result.could u help me in this regard??
 
Nigel Browne
Ranch Hand
Posts: 703
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please post your code, so that we can see what is going on.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you ever studied Boolean Algebra? You could get the bit patterns for two numbers and add them the hard way, just like the CPU does. See if this makes any sense at all: http://thalia.spec.gmu.edu/~pparis/classes/notes_101/node109.html

Frankly, this sounds like a ton of fun to implement ... make HalfAdder and FullAdder objects, chain them together. Extremely geeky.
 
Rene Smith
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
a ton of fun for you maybe I have studied boolean math and yuk - lets not and say we did
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic