From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Ludovic_Court=C3=A8s?= Newsgroups: gmane.lisp.guile.devel Subject: Re: Immediate doubles (up to 2^256) and rationals coming to Guile 3 Date: Fri, 07 Jun 2019 21:46:16 +0200 Message-ID: <87o939b2lz.fsf@gnu.org> References: <87zhmvaw5p.fsf@netris.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="168170"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux) Cc: Andy Wingo , guile-devel To: Mark H Weaver Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Jun 07 22:04:00 2019 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hZL5g-000gq7-EN for guile-devel@m.gmane.org; Fri, 07 Jun 2019 22:03:56 +0200 Original-Received: from localhost ([::1]:52486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZKtY-0006a3-Rz for guile-devel@m.gmane.org; Fri, 07 Jun 2019 15:51:24 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:44060) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hZKok-0002m7-N0 for guile-devel@gnu.org; Fri, 07 Jun 2019 15:46:27 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:54540) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hZKoj-00071J-Sh; Fri, 07 Jun 2019 15:46:25 -0400 Original-Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=49006 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1hZKoe-00007K-1b; Fri, 07 Jun 2019 15:46:21 -0400 X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 19 Prairial an 227 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu In-Reply-To: <87zhmvaw5p.fsf@netris.org> (Mark H. Weaver's message of "Thu, 06 Jun 2019 05:40:39 -0400") X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: "guile-devel" Xref: news.gmane.org gmane.lisp.guile.devel:19950 Archived-At: Hi Mark, Mark H Weaver skribis: > I've found a way to efficiently support both immediate IEEE binary-64 > doubles up to ~1.158e77 (with larger ones transparently allocated on the > heap), and also immediate exact rationals with up to 54 binary digits > (~16 decimal digits), without restricting the 64-bit pointer space at > all, and without any loss of arithmetic precision. Woow, impressive, and really clever! As Dave Thompson wrote on IRC yesterday, this can make a significant difference for applications such as graphics and game engines. I hadn=E2= =80=99t read the message yet and thought =E2=80=9Chey, why not make instructions for things like trigonometric functions so you get unboxed floats=E2=80=9D but obviously, as Dave pointed out, that wouldn=E2=80=99t scale well. :-) > Here's the format of fixrats on 64-bit systems: > > Srrrrrrxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx0111 > |\____/\___________________________________________________/\__/ > | | | | > | rank (6 bits) data (53 bits) tag > sign [...] > I chose this representation because it allows us to leverage existing > floating-point hardware to efficiently pack fixrats. Simply convert the > denominator to an IEEE double, and now the rank will be in the low bits > of the IEEE exponent field, immediately adjacent to the denominator with > its high bit removed. This simplifies the packing operation. Fun. :-) Fixrats can make rationals more practical in applications where one would have avoided them for performance. IIUC, your plan is to have a different tagging on 32-bit platforms, without fixflos, right? I=E2=80=99m curious to see how much complexity wou= ld entail from that. I don=E2=80=99t know what Andy thinks, but if there=E2=80=99s a good way fo= rward for both 32-bit and 64-bit, it=E2=80=99d be a nice bonus for 3.0! Thanks, Ludo=E2=80=99.