
#1
Feb2212, 07:26 AM

P: 133

Hi,
I have three situations where might be overflow is occuring. I need to write test cases to resolve this problem. I don't know how to continue after this, please any one have suggestions to overcome this. Please help me. 



#2
Feb2212, 09:59 AM

P: 55

Post your code




#3
Feb2212, 10:07 AM

P: 2,477

http://www.phrack.org/issues.html?is...&id=10#article
from the article it says that they cant be detected once they happen. So you need to develop an algorithm to detect it before it happens which can seriously slowdown your program but since its a testcase that may not matter. 



#4
Feb2212, 10:11 AM

P: 2,477

signed long integer overflow detection in C
i suppose you could do a second calculation in floating pt and then check to see if the integer answer is in the ballpark of the floating pt answer.




#5
Feb2212, 11:54 AM

HW Helper
P: 6,925

Most processors have an overflow bit for integer math, but most compilers don't provide access to it (short of using inline assembly or assembly callable functions). Checking for overflow on addition can be done by checking to see if both addends have the same sign, and if so, if the sum also has the same sign (else overflow has occurred). Subtraction can be handled by negating the number to subtract and using the addition check. Overflow from multiplication may cause an exception depending on the cpu. If not, multiplication can be checked by dividing the product by one of the multiplicands to see if you get the other multiplicand. Overflow from division may cause an exception depending on the cpu. If not, you need to check the quotient by multiplying the quotient by the divisor to see if it matches the dividend.




#6
Feb2212, 09:54 PM

P: 4,570

If you are using a language with exception catch an exception.
If you are using something where you can add a kind of interrupt hook, then use that. Chances are if you are developing in an environment, then you will be able to do this. From this website: 



#7
Feb2312, 03:20 AM

P: 133





#8
Feb2312, 04:41 AM

P: 133

if((current<0 && rStrom>0)(current>0 && rStrom<0))
{ unerror=unrstromuncurrent; Error = (Signed long)unerror; unerrorint = unerrorint+unerror; ErrorInt = (Signed long)unerrorint; } else { Error=rStromcurrent; ErrorInt=ErrorInt+Error; } I have not tested this yet but i have written the test case like above. All current,rstrom, error and errorint are declared as signed long at the beginning but i casted them to unsigned long to eliminate the overflow and then cast back to signed long. Any suggestions would be appreciated. 


Register to reply 
Related Discussions  
Angular momentum  integer or halfinteger  Quantum Physics  2  
Log Overflow Problem  Precalculus Mathematics Homework  2  
Proof Question: Prove integer + 1/2 is not an integer  Calculus & Beyond Homework  4  
Stack Overflow with Quicksort  Programming & Computer Science  7  
Arithmetic Overflow  Engineering, Comp Sci, & Technology Homework  3 