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,765 of 10,432    |
|    jacob navia to All    |
|    Test for overflow    |
|    30 Mar 15 13:17:27    |
   
   XPost: comp.lang.c   
   From: jacob@jacob.remcomp.fr   
      
   Hi the math experts!   
      
   When parsing a digit sequence I test for overflow not by calculating the   
   maximum number of digits allowed but just with the test   
      
   tvalue = value * base;   
      
   if (tvalue < value) {   
    // overflow detected   
   }   
      
   I am assuming then that   
      
   if value * base > 2^64 then   
    value * base mod 2^64 < value   
      
   for base >= 2 and base <= 36.   
      
   Is this correct?   
      
   I do not have the proof of it. Maybe one of the math people can help me out?   
      
   --- 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