From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Andreas Schwab Newsgroups: gmane.emacs.devel Subject: Re: Using the GNU GMP Library for Bignums in Emacs Date: Mon, 23 Apr 2018 10:39:32 +0200 Message-ID: <87lgde9v0b.fsf@linux-m68k.org> References: <29f933ac-a6bf-8742-66a7-0a9d6d3e5a88@disroot.org> <83bmecy6fx.fsf@gnu.org> <0d3175d8-d996-651e-b221-71978bde3a65@cs.ucla.edu> <51e619e0-ee38-eb97-6c1d-0925b675290a@disroot.org> <8e12135a-0fcc-7aa3-d000-731d2f26d918@disroot.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1524472669 12892 195.159.176.226 (23 Apr 2018 08:37:49 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Mon, 23 Apr 2018 08:37:49 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) Cc: emacs-devel@gnu.org To: Helmut Eller Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Apr 23 10:37:44 2018 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fAWyk-0003D6-3U for ged-emacs-devel@m.gmane.org; Mon, 23 Apr 2018 10:37:42 +0200 Original-Received: from localhost ([::1]:55382 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAX0p-0008Hk-DP for ged-emacs-devel@m.gmane.org; Mon, 23 Apr 2018 04:39:51 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34267) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fAX0h-0008H2-PJ for emacs-devel@gnu.org; Mon, 23 Apr 2018 04:39:44 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fAX0c-0008EW-UC for emacs-devel@gnu.org; Mon, 23 Apr 2018 04:39:43 -0400 Original-Received: from mail-out.m-online.net ([212.18.0.9]:33524) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fAX0c-0008DY-NR for emacs-devel@gnu.org; Mon, 23 Apr 2018 04:39:38 -0400 Original-Received: from frontend01.mail.m-online.net (unknown [192.168.8.182]) by mail-out.m-online.net (Postfix) with ESMTP id 40V0J75Gmmz1qtdd; Mon, 23 Apr 2018 10:39:35 +0200 (CEST) Original-Received: from localhost (dynscan1.mnet-online.de [192.168.6.70]) by mail.m-online.net (Postfix) with ESMTP id 40V0J752gsz1qqkt; Mon, 23 Apr 2018 10:39:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at mnet-online.de Original-Received: from mail.mnet-online.de ([192.168.8.182]) by localhost (dynscan1.mail.m-online.net [192.168.6.70]) (amavisd-new, port 10024) with ESMTP id nLALuisW9jVU; Mon, 23 Apr 2018 10:39:33 +0200 (CEST) X-Auth-Info: Y2myf5Aw15Uy6I/c5H0K62lo9Ha0u+DncrFIfOF5QE1mEJ3vMgr7yjAJ2KxmRXm9 Original-Received: from localhost (ppp-188-174-147-103.dynamic.mnet-online.de [188.174.147.103]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.mnet-online.de (Postfix) with ESMTPSA; Mon, 23 Apr 2018 10:39:33 +0200 (CEST) Original-Received: by localhost (Postfix, from userid 1000) id BD3FC2C3C0E; Mon, 23 Apr 2018 10:39:32 +0200 (CEST) X-Yow: Now I'm telling MISS PIGGY about MONEY MARKET FUNDS! In-Reply-To: (Helmut Eller's message of "Mon, 23 Apr 2018 07:19:22 +0200") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 212.18.0.9 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.org gmane.emacs.devel:224801 Archived-At: On Apr 23 2018, Helmut Eller 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 () 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, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."