[algogeeks] Re: Problem on overflow

2011-08-30 Thread Ankuj Gupta
If both number are negative shouldn't be b < min_int - a On Aug 28, 11:49 pm, "Avinash LetsUncomplicate.." wrote: > @Saurabh being ready to run your code for unsatisfactory input doesn't > seem more logical than trying to find out if you can do something > about it. i would have loved a kind repl

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread Avinash LetsUncomplicate..
@Saurabh being ready to run your code for unsatisfactory input doesn't seem more logical than trying to find out if you can do something about it. i would have loved a kind reply from you. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To po

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread mohit verma
if( unsigned int (a) + unsigned int (b) < 0) return "overflow" else return "ok"; On Sun, Aug 28, 2011 at 7:23 PM, saurabh singh wrote: > @avinash in that case the number will become negative,It wont remain a > satisfactory input.Try to think logically and believe me once you get the > logic

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread saurabh singh
@avinash in that case the number will become negative,It wont remain a satisfactory input.Try to think logically and believe me once you get the logic you will relent why there is no option to delete previous mails..., On Sun, Aug 28, 2011 at 6:32 PM, Dave wrote: > @Avinash: Give an exam

[algogeeks] Re: Problem on overflow

2011-08-28 Thread Dave
@Avinash: Give an example. Dave On Aug 28, 7:00 am, "Avinash LetsUncomplicate.." wrote: > @dave i was saying if user input a .. he can enter a>intmax then how > to detect overflow? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread Avinash LetsUncomplicate..
@dave i was saying if user input a .. he can enter a>intmax then how to detect overflow? -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send ema

Re: [algogeeks] Re: Problem on overflow

2011-08-28 Thread Prags
@Dave- Thank u frnd By the way, this question was asked recently in Tejas Network. On Sun, Aug 28, 2011 at 10:17 AM, Dave wrote: > @Avinash: maxint is the largest possible integer. There aren't any > integers greater than it. Thus, a can't be greater than maxint. For > example, if an int is

[algogeeks] Re: Problem on overflow

2011-08-27 Thread Dave
@Avinash: maxint is the largest possible integer. There aren't any integers greater than it. Thus, a can't be greater than maxint. For example, if an int is 32 bits, maxint = 2^31 - 1. Dave On Aug 27, 10:41 pm, "Avinash LetsUncomplicate.." wrote: > @dave i was saying if user enter a+b in which a

[algogeeks] Re: Problem on overflow

2011-08-27 Thread Dave
@Kunal: You are very kind. Dave On Aug 27, 12:58 pm, Kunal Patil wrote: > @Dave: Still your approach to solve the problem remains correct. > (subtracting a number from max possible value & then comparing this > difference with another number). So, no need to think that you were brain > dead (If

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Kunal Patil
@Dave: Still your approach to solve the problem remains correct. (subtracting a number from max possible value & then comparing this difference with another number). So, no need to think that you were brain dead (If you were, you would have posted a movie story here)..[?] Mathematically it is wrong

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread dipit grover
Oops, I just saw that Dave had already corrected it. Net problem, sorry guys! On Sat, Aug 27, 2011 at 11:02 PM, dipit grover wrote: > I think you just need to reverse the comparison operators in Dave's earlier > post > > > On Sat, Aug 27, 2011 at 10:59 PM, Dave wrote: > >> @Abishek: I was brain-

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread dipit grover
I think you just need to reverse the comparison operators in Dave's earlier post On Sat, Aug 27, 2011 at 10:59 PM, Dave wrote: > @Abishek: I was brain-dead in my earlier posting. Let me try again: > > If either number is zero, the sum will not overflow. > If the numbers have different signs, the

[algogeeks] Re: Problem on overflow

2011-08-27 Thread Dave
@Abishek: I was brain-dead in my earlier posting. Let me try again: If either number is zero, the sum will not overflow. If the numbers have different signs, the sum will not overflow. If both numbers are positive, overflow will occur if b > maxint - a. If both numbers are negative, overflow will

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Abhishek
@Dave: i didn't understand, suppose a=3, b=31000 and MaxInt=32000; you are saying if (MaxInt-a)>=b; then overflow will occur. but here condition is not satisfying. plz explain. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To view this

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Kunal Patil
@Dave: +1 for nice solution... :) On Sat, Aug 27, 2011 at 10:12 PM, Dave wrote: > @Avinash: What do you mean by "exceeding limit(already overflowed)"? > The number maxint is the limit. Every positive number is <= maxint. > > Dave > > On Aug 27, 10:31 am, "Avinash LetsUncomplicate.." 2...@gmail.

[algogeeks] Re: Problem on overflow

2011-08-27 Thread Dave
@Avinash: What do you mean by "exceeding limit(already overflowed)"? The number maxint is the limit. Every positive number is <= maxint. Dave On Aug 27, 10:31 am, "Avinash LetsUncomplicate.." wrote: > @dave if number a is entered exceeding limit(already overflowed) then > a goes negative(if a wa

Re: [algogeeks] Re: Problem on overflow

2011-08-27 Thread Avinash LetsUncomplicate..
@dave if number a is entered exceeding limit(already overflowed) then a goes negative(if a was entred just more than limit ) /a goes positive (if a was entred sufficiently more than limit ) maxint -a>=b concept fails Avinash Katiyar NIT Allahabad -- You received this message because you are s

[algogeeks] Re: Problem on overflow

2011-08-27 Thread Dave
@Prags: Pseudocode: If either number is zero, the sum will not overflow. If the numbers have different signs, the sum will not overflow. If both numbers are positive, overflow will occur if maxint - a >= b. If both numbers are negative, overflow will occur if maxint + a >= -b. Dave On Aug 27, 8: