@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.." <avin. [email protected]> wrote: > @dave i was saying if user enter a+b in which a>intmax .. A goes > negative(if a sligtly >intmax) a+b =no overflow which we know > shouldnt be an answer.. > > On 8/28/11, Dave <[email protected]> wrote: > > > > > > > @Kunal: You are very kind. > > > Dave > > > On Aug 27, 12:58 pm, Kunal Patil <[email protected]> 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 you were, you would have posted a movie story here)..[?] > >> Mathematically it is wrong, not in terms of approach..[?] > > >> On Sat, Aug 27, 2011 at 11:02 PM, dipit grover > >> <[email protected]>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 <[email protected]> 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 sum will not overflow. > >> >> If both numbers are positive, overflow will occur if b > maxint - a. > >> >> If both numbers are negative, overflow will occur if b < -maxint - a - > >> >> 1. > > >> >> Dave > > >> >> On Aug 27, 12:18 pm, Abhishek <[email protected]> wrote: > >> >> > @Dave: i didn't understand, > >> >> > suppose a=30000, 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 post to this group, send email to [email protected]. > >> >> To unsubscribe from this group, send email to > >> >> [email protected]. > >> >> For more options, visit this group at > >> >>http://groups.google.com/group/algogeeks?hl=en. > > >> > -- > >> > Dipit Grover > >> > B.Tech in CSE > >> > IIT Roorkee > > >> > -- > >> > You received this message because you are subscribed to the Google > >> > Groups > >> > "Algorithm Geeks" group. > >> > To post to this group, send email to [email protected]. > >> > To unsubscribe from this group, send email to > >> > [email protected]. > >> > For more options, visit this group at > >> >http://groups.google.com/group/algogeeks?hl=en. > > >> 361.gif > >> < 1KViewDownload > > >> 360.gif > >> < 1KViewDownload- Hide quoted text - > > >> - Show quoted text - > > > -- > > You received this message because you are subscribed to the Google Groups > > "Algorithm Geeks" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]. > > For more options, visit this group at > >http://groups.google.com/group/algogeeks?hl=en. > > -- > Sent from my mobile device- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
