st******@gmail.com wrote:
In my program, the calculated value is supposed to be no more than the
constants named MAXINT,otherwise, the overflow error will be reported,
however, I cannot test if the value exceeds MAXINT within the integer
scope smaller than MAXINT, so I want to seek a solution to test the
excess without comparing the value with MAXINT. Please let me know if
you have a good idea.
THX.
Quote: "I cannot test if the value exceeds MAXINT within the integer
scope smaller than MAXINT [...]"
Do you mean to say the scope you use in your program is
MININT <= SCOPE_MIN <= YOUR_DATA <= SCOPE_MAX <= MAXINT ?
If so, why can't you test this? And what's the big difference between
testing for a set overflow flag (I am not sure the standard even demands
compilers to set such a flag on integer overflow) and testing against
SCOPE_MAX?
Maybe if you include a relevant portion of the code involved we might be
able to be of more help.
Sh.
PS Please don't post same stuff twice under different titles. We got the
point the first time.