emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Using the GNU GMP Library for Bignums in Emacs


From: Andreas Schwab
Subject: Re: Using the GNU GMP Library for Bignums in Emacs
Date: Mon, 23 Apr 2018 10:39:32 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

On Apr 23 2018, Helmut Eller <address@hidden> wrote:

> Out of curiousity: what's the quickest way to detect overflow on
> multiplication in ANSI C?  E.g.
>
>   int64_t x, y, result;
>   result = x * y;
>   if (<how to detect overflow?>)

There is no way to detect overflow after the fact because overflow
invokes undefined behaviour.  You need to either check the range
beforehand, or use special builtins offered by the compiler
(eg. __builtin_smul_overflow in GCC).

Andreas.

-- 
Andreas Schwab, address@hidden
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]