From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#41347: 28.0.50; calculator.el: Cannot input negative exponents Date: Mon, 18 May 2020 11:28:21 +0200 Message-ID: <4D0C7ECD-7179-435A-9783-08F05E8CC204@acm.org> References: <60FECFFF-BF00-4D6A-9297-105B1E1B69C8@acm.org> Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.14\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_24B401BB-4062-49FC-9713-FB7B92A3D9A4" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="70904"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 41347-done@debbugs.gnu.org, Chris Zheng To: Eli Barzilay Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 18 11:29:23 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 1jac5L-000IJy-0R for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 May 2020 11:29:23 +0200 Original-Received: from localhost ([::1]:35658 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jac5K-0000Ae-2O for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 18 May 2020 05:29:22 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52776) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jac50-0008Q2-IV for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 05:29:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34365) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jac50-0003iB-9r for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 05:29:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jac50-0002Ig-63 for bug-gnu-emacs@gnu.org; Mon, 18 May 2020 05:29:02 -0400 Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Mon, 18 May 2020 09:29:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 41347 X-GNU-PR-Package: emacs Mail-Followup-To: 41347@debbugs.gnu.org, mattiase@acm.org, chriszheng99@gmail.com Original-Received: via spool by 41347-done@debbugs.gnu.org id=D41347.15897941108796 (code D ref 41347); Mon, 18 May 2020 09:29:01 +0000 Original-Received: (at 41347-done) by debbugs.gnu.org; 18 May 2020 09:28:30 +0000 Original-Received: from localhost ([127.0.0.1]:45911 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jac4U-0002Hm-9Y for submit@debbugs.gnu.org; Mon, 18 May 2020 05:28:30 -0400 Original-Received: from mail157c50.megamailservers.eu ([91.136.10.167]:56538 helo=mail51c50.megamailservers.eu) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jac4R-0002Hb-1z for 41347-done@debbugs.gnu.org; Mon, 18 May 2020 05:28:28 -0400 X-Authenticated-User: mattiase@bredband.net DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megamailservers.eu; s=maildub; t=1589794104; bh=eIeRZ6c5be0ZuyP/LNv7kIez18vyybQxGyeX1IgsS9c=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=OQ2x1eTBOp5J7fqEiN0qPbtPH3VkL6bFHFQpTa+bSwxB8/v9FT3qn61v/swjgEUGv eZ7Tkt2YGUAR6m9jROq4JtuwVPgCLqDQPqxj7gAv/fMbBE24MxK6QKQdg/kEoHG3Bl 29yPSrtVvNQV0++dkqJlsYKZppyjZSA1jk1tzeqs= Feedback-ID: mattiase@acm.or Original-Received: from stanniol.lan (c-4e4ae655.032-75-73746f71.bbcust.telenor.se [85.230.74.78]) (authenticated bits=0) by mail51c50.megamailservers.eu (8.14.9/8.13.1) with ESMTP id 04I9SM2B017695; Mon, 18 May 2020 09:28:23 +0000 In-Reply-To: X-Mailer: Apple Mail (2.3445.104.14) X-CTCH-RefID: str=0001.0A782F1A.5EC254EA.0039:SCFSTAT68638221, ss=1, re=-4.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-CTCH-VOD: Unknown X-CTCH-Spam: Unknown X-CTCH-Score: -4.000 X-CTCH-Flags: 0 X-CTCH-ScoreCust: 0.000 X-CSC: 0 X-CHA: v=2.3 cv=MOMeZ/Rl c=1 sm=1 tr=0 a=klNLuyVZdLUgl+K5Uafb2A==:117 a=klNLuyVZdLUgl+K5Uafb2A==:17 a=M51BFTxLslgA:10 a=_MzN3rHgAAAA:8 a=qB_FPJd66z8_ubUs-1oA:9 a=CjuIK1q_8ugA:10 a=xx2g9Q9Gyu3bog0EgxsA:9 a=B2y7HmGcmWMA:10 a=5BNEB7gNdRn6NHbpoR6W:22 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:180532 Archived-At: --Apple-Mail=_24B401BB-4062-49FC-9713-FB7B92A3D9A4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii 17 maj 2020 kl. 22.26 skrev Eli Barzilay : > the idea is to mimic common calculators > where you can type "3." or "3e" and get 3. Thank you Eli! I can confirm that after removing all the string = transformation prior to the call to string-to-number, everything works = as expected except "1.e3" (dot before E). A single transformation taking = care of that case was added for the sake of completeness. The attached patch has now been pushed to master. --Apple-Mail=_24B401BB-4062-49FC-9713-FB7B92A3D9A4 Content-Disposition: attachment; filename=0001-Fix-calculator-entry-of-numbers-with-negative-expone.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Fix-calculator-entry-of-numbers-with-negative-expone.patch" Content-Transfer-Encoding: quoted-printable =46rom=20482baa9856e4269bdf8f253621013592bc8de5b2=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20=3D?UTF-8?q?Mattias=3D20Engdeg=3DC3=3DA5rd?=3D=20= =0ADate:=20Sun,=2017=20May=202020=2018:11:27=20+0200=0A= Subject:=20[PATCH]=20Fix=20calculator=20entry=20of=20numbers=20with=20= negative=20exponents=0A=20(bug#41347)=0A=0A*=20lisp/calculator.el=20= (calculator-string-to-number):=0ARemove=20obsolete=20string=20= transformations=20preventing=20entry=20of=201e-3=20etc.=0AKeep=20one=20= transformation=20to=20allow=20entry=20of=20"1.e3".=0AReported=20by=20= Chris=20Zheng.=0A---=0A=20lisp/calculator.el=20|=2010=20++++------=0A=20= 1=20file=20changed,=204=20insertions(+),=206=20deletions(-)=0A=0Adiff=20= --git=20a/lisp/calculator.el=20b/lisp/calculator.el=0Aindex=20= 7e0b2fcc6a..cd92f99268=20100644=0A---=20a/lisp/calculator.el=0A+++=20= b/lisp/calculator.el=0A@@=20-858,12=20+858,10=20@@=20= calculator-string-to-number=0A=20=20=20"Convert=20the=20given=20STR=20to=20= a=20number,=20according=20to=20the=20value=20of=0A=20= `calculator-input-radix'."=0A=20=20=20(if=20calculator-input-radix=0A-=20= =20=20=20(string-to-number=20str=20(cadr=20(assq=20= calculator-input-radix=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20'((bin=20= 2)=20(oct=208)=20(hex=2016)))))=0A-=20=20=20=20(let*=20((str=20= (replace-regexp-in-string=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20"\\.\\([^0-9].*\\)?$"=20".0\\1"=20str))=0A-=20=20=20=20=20=20=20=20= =20=20=20(str=20(replace-regexp-in-string=0A-=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20"[eE][+-]?\\([^0-9].*\\)?$"=20"e0\\1"=20str)))=0A+=20= =20=20=20=20=20(string-to-number=20str=20(cadr=20(assq=20= calculator-input-radix=0A+=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= '((bin=202)=20(oct=208)=20(hex=2016)))))=0A+=20=20=20=20;;=20Allow=20= entry=20of=20"1.e3".=0A+=20=20=20=20(let=20((str=20= (replace-regexp-in-string=20(rx=20"."=20(any=20"eE"))=20"e"=20str)))=0A=20= =20=20=20=20=20=20(float=20(string-to-number=20str)))))=0A=20=0A=20= (defun=20calculator-push-curnum=20()=0A--=20=0A2.21.1=20(Apple=20= Git-122.3)=0A=0A= --Apple-Mail=_24B401BB-4062-49FC-9713-FB7B92A3D9A4--