File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java" Watch "java" New topic


Sreeram Rajesh

Joined: Mar 17, 2005
Posts: 1
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

Joined: May 15, 2001
Posts: 673
Please post your code, so that we can see what is going on.
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
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:

Frankly, this sounds like a ton of fun to implement ... make HalfAdder and FullAdder objects, chain them together. Extremely geeky.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Rene Smith

Joined: Jun 10, 2004
Posts: 21
a ton of fun for you maybe I have studied boolean math and yuk - lets not and say we did
I agree. Here's the link:
subject: java
It's not a secret anymore!