From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Code for converting between Elisp and Calc floats Date: Mon, 26 Oct 2009 23:22:14 -0400 Message-ID: References: <200910082047.n98KlkAB020482@godzilla.ics.uci.edu> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1256613756 9836 80.91.229.12 (27 Oct 2009 03:22:36 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Tue, 27 Oct 2009 03:22:36 +0000 (UTC) Cc: cyd@stupidchicken.com, emacs-devel To: Vincent =?iso-8859-1?Q?Bela=EFche?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Tue Oct 27 04:22:29 2009 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1N2cdg-0000lX-RX for ged-emacs-devel@m.gmane.org; Tue, 27 Oct 2009 04:22:29 +0100 Original-Received: from localhost ([127.0.0.1]:48323 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2cdg-0004aO-6U for ged-emacs-devel@m.gmane.org; Mon, 26 Oct 2009 23:22:28 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2cdZ-0004aB-Tn for emacs-devel@gnu.org; Mon, 26 Oct 2009 23:22:21 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2cdV-0004Yj-4e for emacs-devel@gnu.org; Mon, 26 Oct 2009 23:22:21 -0400 Original-Received: from [199.232.76.173] (port=40819 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2cdU-0004Yg-Un for emacs-devel@gnu.org; Mon, 26 Oct 2009 23:22:16 -0400 Original-Received: from ironport2-out.teksavvy.com ([206.248.154.183]:35204 helo=ironport2-out.pppoe.ca) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2cdU-0001MQ-NA for emacs-devel@gnu.org; Mon, 26 Oct 2009 23:22:16 -0400 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ArEEAIAE5kpLd/xb/2dsb2JhbACBUNZ6hD8EgV+GVw X-IronPort-AV: E=Sophos;i="4.44,629,1249272000"; d="scan'208";a="48213631" Original-Received: from 75-119-252-91.dsl.teksavvy.com (HELO pastel.home) ([75.119.252.91]) by ironport2-out.pppoe.ca with ESMTP; 26 Oct 2009 23:22:15 -0400 Original-Received: by pastel.home (Postfix, from userid 20848) id D5B778013; Mon, 26 Oct 2009 23:22:14 -0400 (EDT) In-Reply-To: ("Vincent =?iso-8859-1?Q?Bela=EFche=22's?= message of "Mon, 26 Oct 2009 13:48:59 +0100") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.50 (gnu/linux) X-detected-operating-system: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:116416 Archived-At: >> Also, the mantissa should probably be represented as either a single >> integer or a list of integers where each integer provides 16bits of data >> (that's a format already used elsewhere in Emacs to represent "large >> integers" such as for time). > I did it this way because it allowed a simpler algorithm: in the > conversion algorithm the integer size step is based on the number of > decimal digits that Calc uses in representing big integers. The Calc > big integers are not composed of 16bits integers (and actually there > is not an integral number of bits, because these components are in > radix 10). From that perspective it was easier if the number of bits > of each component integer is passed along with the component integer > in the interface. I understand the code is simpler on the Lisp side, but I'm more concerned about the C side. Of course, if the Lisp side becomes unmanageable it's also relevant. >> I'd also rename the mantissa and exponent size info, or maybe even >> consider providing it differently (in case its use is always linked to >> calls to one of the previous 2 functions, maybe those functions could >> return the relevant info. E.g. make-float could return the part of the >> mantissa it ignored). Since you're using those constants, you clearly >> know better how they're used, so I'll let you figure out whether there's >> a better way to ptovide the same info. > OK, this can be improved. Actually, my intention was not that these > builtin functions were kind-of part of Calc library API, these are > really internal things that the user developing above Calc should > not need. I understand they're not Calc-specific althought they'd currently only be used by Calc. That's good. Still, Calc is the best sample-use we have, so it's what we have to guess at what a good API should look like. >> Also, how is math-lisp-float-binary-ieee754-conformance used? > This is the switch between the two types of implementations: the one > using builtin support, and the one not needing builtin support. So (fboundp 'construct-float) would work as well? > Note that I can imagine that it is possible to implement the > construct/deconstruct builtin functions just using Lisp, this is after > all just a matter of generating clean powers of 2. But, since this > code would be so machine/system dependant, and since Lisp would be so > more uselessly complex than C code,I thought that it was a better > choice to make it in C. I think it fits better in C. Basically, it would be the equivalent to C's frexp. Stefan