From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Emanuel Berg via help-gnu-emacs Newsgroups: gmane.emacs.help Subject: Re: Calculator: no exponent, full number ? Date: Thu, 06 Jun 2019 18:50:55 +0200 Message-ID: <86wohyodxs.fsf@zoho.eu> References: <20190604154307.565d33cf@mistral> <87zhmwzn67.fsf@mbork.pl> <20190605095317.499f2082@mistral> <86tvd3sig6.fsf@zoho.eu> <875zpibtr3.fsf@mbork.pl> Reply-To: Emanuel Berg Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="114954"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (gnu/linux) Cc: Ingemar Holmgren To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Thu Jun 06 18:51:33 2019 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1hYvbw-000Tga-NB for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Jun 2019 18:51:32 +0200 Original-Received: from localhost ([127.0.0.1]:35240 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYvbv-0000EZ-EX for geh-help-gnu-emacs@m.gmane.org; Thu, 06 Jun 2019 12:51:31 -0400 Original-Received: from eggs.gnu.org ([209.51.188.92]:60391) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hYvbc-00009W-4s for help-gnu-emacs@gnu.org; Thu, 06 Jun 2019 12:51:13 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hYvbX-0003zL-TJ for help-gnu-emacs@gnu.org; Thu, 06 Jun 2019 12:51:09 -0400 Original-Received: from [195.159.176.226] (port=35674 helo=blaine.gmane.org) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hYvbU-0003hq-Hu for help-gnu-emacs@gnu.org; Thu, 06 Jun 2019 12:51:06 -0400 Original-Received: from list by blaine.gmane.org with local (Exim 4.89) (envelope-from ) id 1hYvbS-000T0y-3B for help-gnu-emacs@gnu.org; Thu, 06 Jun 2019 18:51:02 +0200 X-Injected-Via-Gmane: http://gmane.org/ Mail-Followup-To: help-gnu-emacs@gnu.org Mail-Copies-To: never Cancel-Lock: sha1:nTIGUsDuKmL+S/zJG/K1gIEePNU= X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 195.159.176.226 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:120779 Archived-At: Marcin Borkowski wrote: >> (defun hypotenuse (c1 c2) >> (sqrt (+ (* c1 c1) (* c2 c2))) ) > > Just for the fun, let me mention that this is > not a very good algorithm for computing the > Pythagorean sum - it may happen that both the > operands and the result lie within the bounds > for the given type but this calculation blows > up because of large squares overflowing. Well, first let it be known that Marcin is a professional mathematician, famous for his remarkable calculations. That said, the above comment is on the computer side of things, right? In the math world, what would happen is just a very large triangle, again - right? Assuming integers, how large can they be in Emacs Lisp? Eval us: most-positive-fixnum ; 536870911 "Typical values are 2**29 − 1 on 32-bit and 2**61 − 1 on 64-bit platforms." [1] most-negative-fixnum ; -536870912 "Typical values are −2**29 on 32-bit and −2**61 on 64-bit platforms." [1] How do you know if your "platform" (i.e. kernel?) is 32- or 64-bit? Tricky, but here is an incomplete guide from the systems I have access to: Debian Intel: uname -m; i686 -> 32-bit, x86_64 -> 64 OpenBSD: uname -m; amd64 -> 64 (same type as x86-64 BTW) RPi3 Raspbian: uname -m; armv7l -> 32 SunOS/Solaris: 'isainfo -kv' tells you Also remember that you can have 64 HW but still a 32 Linux kernel - but probably not the other way around :)) (?) Otherwise you can use Emacs to find out! most-positive-fixnum ; 536870911 then compute 2**29 - 1: # /bin/zsh $ echo $(( 2**29 − 1 )) 536870911 so yes, it checks out for my RPi3 :) > Also, it is slow because of the need to > compute square roots. Interestingly, there > exists a clever algorithm that does not have > these problems. Why don't you post it in Elisp to prove my point one can use Elisp for math, even advanced math! <3 > It is used (among others) in Donald Knuth's > METAFONT. The algorithm is described in the > paper (using Emanuel's favorite format;-)): That's true, I frekking *love* Biblatex! [2] > @ARTICLE{5390405, > author={C. {Moler} and D. {Morrison}}, > journal={IBM Journal of Research and Development}, > title={Replacing Square Roots by Pythagorean Sums}, > year={1983}, > volume={27}, > number={6}, > pages={577-581}, > keywords={}, > doi={10.1147/rd.276.0577}, > ISSN={0018-8646}, > month={Nov}, > } Only I keep mine much neater :) @book{land-of-lisp, author = {Conrad Barski}, isbn = 1593272812, publisher = {No Starch}, title = {Land of Lisp}, year = 2010 } @book{lispcraft, author = {Robert Wilensky}, isbn = 0393954420, publisher = {Norton}, title = {LISPcraft}, year = 1984 } %% [3] [1] (info "(elisp) Integer Basics") [2] https://dataswamp.org/~incal/emacs-init/my-bibtex.el [3] https://dataswamp.org/~incal//books/books.bib -- underground experts united http://user.it.uu.se/~embe8573 https://dataswamp.org/~incal