Hi guys,
I have a problem. I want to find whether the sum of two numbers is negative or positive without using any arithmetic calculations may be + ,* % etc... Can somebody help me. I need it urgently.
Thank you.
Printable View
Hi guys,
I have a problem. I want to find whether the sum of two numbers is negative or positive without using any arithmetic calculations may be + ,* % etc... Can somebody help me. I need it urgently.
Thank you.
Compare the numbers and look at their signs:
If both are positive the sum is positive.
If both are negative the sum is negative.
If one is positive and the other negative, then the sum will be positive if the positive number has the larger modulus, and negative if it's the negative number that has the larger modulus.
As for the case of one or both being 0... I leave this to you.
Hi krtxmrtz,
But still you need to subtract two number for comparing. I want to find whether sum of 2 numbers is -ve or +ve without using any arithmetic calculations that may be add,subtract ,mul,div,mod ,abs etc....Please help. I need it urgently.
Thank You.
you give the two numbers two your friend, and he'll tell you which one is bigger
Why can't you use any arithmetic- I can't think of any valid business or technical reason, so this must be homework, right? What a dumb assignment.
:D it certainly is...Quote:
Originally posted by Spooner
Why can't you use any arithmetic- I can't think of any valid business or technical reason, so this must be homework, right? What a dumb assignment.
pmsays, what is wrong with the method that krtxmrtz posted? I cant see any reason to subtract anything! Try learning about > , < , and = (oh, and abs might help too)
But using <, > , abs etc is using arithemtic. I can't see a way to do it without.
Maybe it's a riddle?
When you say the sum is positive or negative, you are comparing it to 0. Why then shouldn't comparisons be allowed?
If you can think of an alternative method to decide whether the sum is positive or negative, then maybe you could apply this method to the 2 numbers.
well your question already has an arithmetic sign in it:rolleyes:
well if you wanna be technical you could convert them to strings and use Mid$ to check each char, left to right, checking for signs and digits... that wouldn't have to use any arithmetic, just a lot of boolean logic...
You want to check a mathematical inequality without using maths?
Well, if u had only integers, try this:
Get a (large) number of red and blue balls.
Now, for each number X, if X is negative, put down X red balls.
if X is positive, put down X blue balls.
When you have done this, take away pairs of blue and red balls, until you have no balls left of one colour.
If you have only red balls left, the sum is negative
If you have only blue balls left, the sum is positive
If you have NO balls left, the sum is zero.
:D:D:D
:D
Recognising that a number is a value and then counting out the right number of balls is itself a mathematical activity. ;)
yes, counting is just as much a mathematical function as any. this is an odd assignment, try the string manipulation and see if you can get it