Jun 5, 2006

Middle Path

1 comment:

Anonymous said...

Hey Ramanand,
The overflow problem arises even in the oh-so-oft-repeated-interview-question to swap 2 numbers without a third variable.
We usually do a=a+b; b=a-b; a=a-b;
But then for very high values of a or b it results in overflow. Simple way to avoid overflow is to use XOR instead of + or -