On 09/20/2016 04:51 PM, Scott Hess wrote:

No patch suggested, though I wouldn't be surprised if my brain makes a
suggestion after things simmer for an hour or so.  If either value
needs less than 31 bits, it can't happen, but there's not a simple bit
pattern to check, AFAICT.

Unless performance is of uttermost importance, just try and see if it fails or not.

prod = x * y;
if (y != 0) {
  if (prod / y != x) {
    /* Overflow. */

This also works for multiplications such as 1152921504606846976 * 3, which do not overflow, but have much bigger multiplicands.

Bernardo Sulzbach
sqlite-users mailing list

Reply via email to