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,771 of 10,432    |
|    James Kuyper to jacob navia    |
|    Re: Test for overflow    |
|    31 Mar 15 13:41:12    |
   
   XPost: comp.lang.c   
   From: jameskuyper@verizon.net   
      
   On 03/31/2015 01:11 AM, jacob navia wrote:   
   > I hope this doesn't go into your kill file... Anyway   
      
   So far, you haven't used you new e-mail address to say anything that   
   made me want to to add it to my kill file.   
      
   > 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?   
      
   I think so, so long as 'digit' is no wider than 'value' - given the   
   context, if they were different sizes, I'd expect 'digit' to be smaller,   
   so that shouldn't be a problem. Of course, my judgement is more reliable   
   when I say there's a problem than when I say there's no problem.   
      
   > 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