From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Chris Zheng Newsgroups: gmane.emacs.bugs Subject: bug#41347: 28.0.50; calculator.el: Cannot input negative exponents Date: Sun, 17 May 2020 13:53:12 +0800 Message-ID: <20200517055312.jtwughazs453lbzt@Kael> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="98646"; mail-complaints-to="usenet@ciao.gmane.io" To: 41347@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun May 17 07:54:10 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 1jaCFW-000PYV-BM for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 07:54:10 +0200 Original-Received: from localhost ([::1]:42352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jaCFV-0000OL-3j for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 17 May 2020 01:54:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52618) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaCFP-0000OD-0u for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 01:54:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58858) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaCFO-0002wv-OE for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 01:54:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jaCFO-0002Zm-LY for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 01:54:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Chris Zheng Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 17 May 2020 05:54:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 41347 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.15896948069853 (code B ref -1); Sun, 17 May 2020 05:54:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 17 May 2020 05:53:26 +0000 Original-Received: from localhost ([127.0.0.1]:42171 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaCEo-0002Yr-CW for submit@debbugs.gnu.org; Sun, 17 May 2020 01:53:26 -0400 Original-Received: from lists.gnu.org ([209.51.188.17]:41424) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jaCEm-0002Yj-RE for submit@debbugs.gnu.org; Sun, 17 May 2020 01:53:25 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jaCEm-0000Mz-8A for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 01:53:24 -0400 Original-Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]:33288) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jaCEl-0002ve-Du for bug-gnu-emacs@gnu.org; Sun, 17 May 2020 01:53:23 -0400 Original-Received: by mail-pl1-x636.google.com with SMTP id t7so2772051plr.0 for ; Sat, 16 May 2020 22:53:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mime-version:content-disposition; bh=YuyxPvfdSPgPD6KU7NZL6M5QIHYm5hRSke6qFmyrFeA=; b=gORrYPTvLZ7TpwP3jcyNdiYQGvZIDcR0bB44oEsRxMjcQoBqLX980eWGztLVb9cRjl 8FyC539GWNRkPUUpkoMcalaS4DBpWNEGyEQ21qMUPhySNpAgyR8aeo9su+nQUrTicoP5 tDmsJSpZVpr5ur72iUigNog2fqOSvng3UxF1mmP9/Fd+fQ+Vr2s6T6gqIfuISM2M9D5s 993z9dhe7t/ZakFzrFvBRlfjeWYvdmGheqLfGcBNBP+TxFiURt0G1WKjK5wOcR7FA6tH iksFoPa19j0T85goUlzXqf3dWIUjkEJGjtiO0PNGsYDh6j8neLkYZiMtim1mdhjPEaJH vjtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mime-version :content-disposition; bh=YuyxPvfdSPgPD6KU7NZL6M5QIHYm5hRSke6qFmyrFeA=; b=horfuUB0ANtILyB6L1x4QeWhi+yqCwKmjwW5tUS2ZMFfROS85EB6A+x8S3uzEb1Z+J KGj0wOYorCZUo+xb5iCtMtnhHenlpQHzbdfdTR/zutIplwi1I8pVLvbnZyu7QlUbNFXg ACmD+YcPslaP0Two10vtOVRC7ixJgLOcs2KQ5CeZHZi0WuulVSAVvNRDGD2hL0SkcxaW Ep8YPDbXNaXAlV44Xz3lK/NI2ucxE2IkCfMBracZ0Kt/i4sHX3cr5wHJxa15sv7dm/sN 9EheUnCkKPjuyqM3gL9eG9g2IDhq+SOKyXEbHKG7RgRMvBq+lFxjm0X0I9+grfEwfco5 H9AA== X-Gm-Message-State: AOAM531O9VPojXE5bXA9uK8mEfrzxOmrixtrxD6yaiEewKFExIb4pkeN wcjWsrBlLBKLpbdhQeL5KHmYa7KE X-Google-Smtp-Source: ABdhPJzG5AgFcH517BIrAfc1tBXY5buruc13kaO46hjGRWyn5pmPfgyR1m8RBLqarOPk0TE5dLxTPw== X-Received: by 2002:a17:902:bc89:: with SMTP id bb9mr10927640plb.101.1589694801158; Sat, 16 May 2020 22:53:21 -0700 (PDT) Original-Received: from Kael ([67.230.166.176]) by smtp.gmail.com with ESMTPSA id d7sm5761045pfa.63.2020.05.16.22.53.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 16 May 2020 22:53:20 -0700 (PDT) Content-Disposition: inline Received-SPF: pass client-ip=2607:f8b0:4864:20::636; envelope-from=chriszheng99@gmail.com; helo=mail-pl1-x636.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_PASS=-0.001 autolearn=_AUTOLEARN X-Spam_action: no action 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:180435 Archived-At: Hello, With current master, starting Emacs with `-Q`: 1. M-x calculator 2. Input 1e-3 RET You will get 1 instead of 0.001. I believe this happens since Emacs 26.1. The root cause is the `calculator-string-to-number` function in lisp/calculator.el. Now the function gives (calculator-string-to-number "1e-3") => 1.0 (calculator-string-to-number "1e3") => 1000.0 (calculator-string-to-number "1e") => 1.0 The funcional code is (replace-regexp-in-string "[eE][+-]?\\([^0-9].*\\)?$" "e0\\1" str) It changes `1e-3` to `1e0-3` that is recognized as 1. I have a possible fix attached below. Please see if it is correct. Thank you, Chris Zheng From 7693d7072e4787c4b0663f490be5d83c1d9a6ee3 Mon Sep 17 00:00:00 2001 From: Chris Zheng Date: Sun, 17 May 2020 13:43:35 +0800 Subject: [PATCH 1/1] Fix calculator exponent input * lisp/calculator.el (calculator-string-to-number): Change the regexp to correctly deal with negative exponents. --- lisp/calculator.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lisp/calculator.el b/lisp/calculator.el index 7e0b2fcc6a..fa3eb19099 100644 --- a/lisp/calculator.el +++ b/lisp/calculator.el @@ -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))))) (defun calculator-push-curnum () -- 2.16.1.windows.1