 Search:

# how to wite the java projaram ading to numbes wothot addition(+)

Asked By: Ryan    Date: Aug 21    Category: Java    Views: 623

Share:

You can use the fact that

x+y = ( sqr(x)-sqr(y) ) / (x-y)

What GoodMan said is correct, he just didnt put it in a understandable way..

Herez what he is trying to say..

If u want to add A and B use the following exp

sum = ((A*A)-(B*B))/A-B

It can be done in a simpler way like -

int x, y;
x = 7;
y = 5;
int z = -1 * (0 - x - y);

Isn't it?

I do not think that what you are telling will work. Have you tried
putting that to code and testing it out?

int x, y;
x = -7;
y = 5;
int z = -1 * (0 - x - y);

Isn't it?

simple maths guys..

(A+b)(A-B)=SQ(A)-SQ(B)

so the goodman formula was correct.

simple maths guys..

(A+b)(A-B)=SQ(A)-SQ(B)

so the goodman formula was correct.

How would that apply when -
x = 2 and y = 2
or any other similar situation?

No one ever said that the original question makes much sense. In my
opinion the OP (how to add x + y without using the + operator) is sort
of useless; in fact I've NEVER seen a situation in my whole IT life
(and this lasts for almost 27 years by now) when I would have needed
to add two values without the possibility to add them using the +
operator (except of course when writing a compiler in assembler). So
this sort of questions is in my personal opinion(!) futile; a waste of
time, at best an intellectually challenging game (but to no avail).

You are right, x == -2 and y == +2 is not covered by the approach
given above, but then Good Man just gave a short hint as to how to
approach the question; he did not at all claim he had given a complete
solution.

to an extent you r vry right that there
would never b a situation when we will be devoid of
the + operator but these type of questions are
generally asked during the interviews to check the
sharpness of one's mind and how far can one think
beyond the monotonous ways.

o.k., that's a very good point. Thanks for clarifying this; it clearly
shows how monotonously I think in too many respects.

How about negative numbers, too? You will have complex-numbers issue