home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   sci.math.symbolic      Symbolic algebra discussion      10,432 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 8,770 of 10,432   
   jacob navia to All   
   Re: Test for overflow   
   31 Mar 15 07:11:49   
   
   XPost: comp.lang.c   
   From: jacob@jacob.remcomp.fr   
      
   I hope this doesn't go into your kill file... Anyway   
   Now I will do   
      
   maxvalNotOverflow = maxval/base;   
      
   and then, at each step:   
      
        if (value > maxvalNotOverflow) {   
            digit = OVERFLOW_FLAG;   
            break;   
        }   
        else value = value * base;   
      
   Now, I DO believe that my test is OK when testing for an ADDITION overflow.   
      
        if (value+digit < value) {   
            digit = OVERFLOW_FLAG;   
            break;   
        }   
        else value += digit;   
      
   OK?   
      
   Note: ALL values are unsigned.   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca