Why in the first place do you need to check the over
or underflow? What sort of app would need it?


--- Shantanoo <[EMAIL PROTECTED]> wrote:

> On Fri, 24 Sep 2004 19:17:10 +0530, Vishal Rao
> <[EMAIL PROTECTED]> wrote:
> > Hi,
> > 
> > How to detect arithmetic overflow/underflow in C
> and C++?
> > 
> > For example, if I do something like this:
> > 
> > unsigned i = 0;
> > i--;
> 
> new value is i is 4294967295 (max value of
> unsigned).
> 
> 
> > 
> > Whats a good way to detect/catch/trap the
> underflow?
> > 
> > Right now I do something like:
> > 
> > unsigned iPrev = i;
> > i--;
> > if (iPrev<i) return MYERROR_UNDERFLOW;
> 
> Whenever there is increment, store that value in
> iPrev. and Before
> increment, check new value is greater than iPrev.
> 
> Can't understand your exact prob. So maybe this is
> vague answer.
> Why not write a function
> ModifyVariable(newValue,oldValue) which will
> take care of all necessary things?
> 
> > 
> > Cheers,
> > Vishal
> >
> --
>
______________________________________________________________________
> Pune GNU/Linux Users Group Mailing List:     
> ([EMAIL PROTECTED])
> List Information: 
> http://plug.org.in/mailing-list/listinfo/plug-mail
> Send 'help' to [EMAIL PROTECTED] for
> mailing instructions.
> 



                
__________________________________
Do you Yahoo!?
Yahoo! Mail is new and improved - Check it out!
http://promotions.yahoo.com/new_mail
--
______________________________________________________________________
Pune GNU/Linux Users Group Mailing List:      ([EMAIL PROTECTED])
List Information:  http://plug.org.in/mailing-list/listinfo/plug-mail
Send 'help' to [EMAIL PROTECTED] for mailing instructions.

Reply via email to