From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Eli Barzilay Newsgroups: gmane.emacs.bugs Subject: bug#41347: 28.0.50; calculator.el: Cannot input negative exponents Date: Sun, 17 May 2020 16:26:39 -0400 Message-ID: References: <60FECFFF-BF00-4D6A-9297-105B1E1B69C8@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="18075"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41347@debbugs.gnu.org, Chris Zheng To: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 17 22:27:24 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jaPsZ-0004Zs-RW for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 22:27:23 +0200 Original-Received: from localhost ([::1]:53318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaPsY-0006l9-Qi for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 16:27:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52976) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaPsG-0006ks-CV for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 16:27:04 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:33325) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaPsE-0000U2-LZ for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 16:27:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jaPsE-0003MN-HU for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 16:27:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Eli Barzilay Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 May 2020 20:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 41347 X-GNU-PR-Package: emacs Original-Received: via spool by 41347-submit@debbugs.gnu.org id=B41347.158974721812904 (code B ref 41347); Sun, 17 May 2020 20:27:02 +0000 Original-Received: (at 41347) by debbugs.gnu.org; 17 May 2020 20:26:58 +0000 Original-Received: from localhost ([127.0.0.1]:44871 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaPsA-0003M4-2T for submit@debbugs.gnu.org; Sun, 17 May 2020 16:26:58 -0400 Original-Received: from mail-ed1-f47.google.com ([209.85.208.47]:36338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaPs8-0003Ls-Uo for 41347@debbugs.gnu.org; Sun, 17 May 2020 16:26:57 -0400 Original-Received: by mail-ed1-f47.google.com with SMTP id b91so6744507edf.3 for <41347@debbugs.gnu.org>; Sun, 17 May 2020 13:26:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=barzilay-org.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=WfD/oVzak5YEKYXXg18yGDvN9E+Qv07JlKH6fsSiTdE=; b=xBaEIo2cX5aJC+1dSD6K/916sPCumzRW3y6SBFH0U07JZxF38rNl4fCrL287EFkGZA zMQtFvIyBlXLZh/xDpP3sX4+ku2Dy3ej+bdCgQIyOJ3mQPuH/CFWA19kaN+pc9dpXnyQ 4PF3bUcBDanWTolxy/x4Z5Q/mVtrDiZmMSabHxqZTxC9vzznEGipNEbdhOcZzdgnUqcF LT9M/WjNHr1fPOZ+I/kHfomM8XsP/v2IdgilkDuPauL21gkf7x8jjUDyJrNjCVA6U7L5 agi2Tp9xIJsno2AhoDVM83EvHc/Mr+B0Vt8my1yf3+SFH0SM0V3r1D7IDmmRO4QL9pOk SSBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=WfD/oVzak5YEKYXXg18yGDvN9E+Qv07JlKH6fsSiTdE=; b=rIcaVK/EtcHz6/4QQGe/4wbnicDgTNZy1FS60A4r8O3ZVFyNeXJ4UnCp3TKU2Mm42c Aivxy9He5r9o3J/GH5yZ/Ymm0eoup4h7e6Pexg7aiN89Y0meE+NRp1MPsbyuiGiEYY0C f6yL+80huA16rEkeTXfhsBjAX72wr6hiHZR6zARFoNuzqE6bgUapAn7sFZlZUsh+RVuX W48mrfzB74y5AalHvUHL1pNUIXSrPx31LACzEf/Z9rhOc+DgtNxn3CkGvMGB02PZJd38 j7MzzwpccKM3q5vsaq6Tr26b3I+6nuinsbrUzRb0ABZgxLDJt8vR+JX51BVMS5YkL1Dg T14g== X-Gm-Message-State: AOAM533JvIOP+sCmD/ZYL9r4Kx6LoOORpoQgD4wP30gS7jF6aEZvHYSg 0KhhDuWMzW4SnWRjamhUch6nZ0ZJ1dY/vgI3PUU9zQ== X-Google-Smtp-Source: ABdhPJwL/0sdrPHwnRtbjSQG2nSirRwjL3LVNM5ND96mqdcpHo6KhG8EE1HFsrle4FpZnYS5yI2rXsPGZnC+viPsR/M= X-Received: by 2002:a50:fa85:: with SMTP id w5mr2985749edr.88.1589747210930; Sun, 17 May 2020 13:26:50 -0700 (PDT) In-Reply-To: <60FECFFF-BF00-4D6A-9297-105B1E1B69C8@acm.org> X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:180509 Archived-At: On Sun, May 17, 2020 at 7:08 AM Mattias Engdeg=C3=A5rd w= rote: > > > @@ -863,7 +863,7 @@ calculator-string-to-number > > (let* ((str (replace-regexp-in-string > > "\\.\\([^0-9].*\\)?$" ".0\\1" str)) > > (str (replace-regexp-in-string > > - "[eE][+-]?\\([^0-9].*\\)?$" "e0\\1" str))) > > + "[eE]\\([+-]?\\)?$" "e\\10" str))) > > (float (string-to-number str))))) > > Thanks for the report and the suggested patch! However, I'm not sure > what either of these replace-regexp-in-string calls are good for. The > first one possibly to accept 1.e23 instead of 1e23; the second one is > less clear. Frankly, I think we can drop both. > > Eli, do you remember? Sidenote: there's not much point in the double "?" in "\\([+-]?\\)?". But more to the point, I don't remember why I switched to the regexp mess in the first place. The original code: (car (read-from-string (cond ((equal "." str) "0.0") ((string-match "[eE][+-]?$" str) (concat str "0")) ((string-match "\\.[0-9]\\|[eE]" str) str) ((string-match "\\." str) ;; do this because Emacs reads "23." as an integer (concat str "0")) ((stringp str) (concat str ".0")) (t "0.0")))) makes the intention clear -- the idea is to mimic common calculators where you can type "3." or "3e" and get 3. (Re the fix from a short while ago, the comment also shows that the original intention was to always get a float.) It looks like going back to a simplified (due to the float) version of this would be better. Also testing that the thing I mentioned in the log still works ("e+" using "+" as an operator). --=20 ((x=3D>x(x))(x=3D>x(x))) Eli Barzilay: http://barzilay.org/ Maze is Life!