From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Schulte Subject: Re: [babel] calc var floating point number error Date: Wed, 25 Jul 2012 09:32:26 -0600 Message-ID: <87pq7jluum.fsf@gmx.com> References: <1342792553.1277.YahooMailNeo@web29802.mail.ird.yahoo.com> <87txx2ijr0.fsf@gmx.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([208.118.235.92]:36731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Su3h5-0000M0-Ph for emacs-orgmode@gnu.org; Wed, 25 Jul 2012 11:40:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Su3gz-0003Xw-H7 for emacs-orgmode@gnu.org; Wed, 25 Jul 2012 11:40:11 -0400 Received: from mailout-us.gmx.com ([74.208.5.67]:47155) by eggs.gnu.org with smtp (Exim 4.71) (envelope-from ) id 1Su3gz-0003XJ-Bt for emacs-orgmode@gnu.org; Wed, 25 Jul 2012 11:40:05 -0400 In-Reply-To: <87txx2ijr0.fsf@gmx.com> (Eric Schulte's message of "Fri, 20 Jul 2012 08:34:43 -0600") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Giovanni Ridolfi Cc: Orgmode Eric Schulte writes: > Giovanni Ridolfi writes: > >> Hello everyone, >> >> GNU Emacs 24.1.1 (i386-mingw-nt6.1.7601) of 2012-06-10 on MARVIN >> Org-mode version 7.8.11 (eed478ffa @=20 >> >> >> I have a problem with babel and calc. >> >> I am not able to pass (as variable) floating point numbers.=C2=A0 >> >> this example works: >> >> #+BEGIN_SRC calc :var thi=3D20 :var tha=3D90 :var a=3D10 :var rho=3D7854= :var cp=3D434 :var r=3D5 >> ?tha -? (tha - thi) * exp((-3.0*a)/(rho*cp*r)) >> #+END_SRC >> >> #+RESULTS: >> : 20.0001232163 >> >> >> However var "r" should be 0.05, but if I use such floating point number = I got an error: >> >> >> #+NAME sphere >> #+BEGIN_SRC calc :var thi=3D20 :var tha=3D90 :var a=3D10 :var rho=3D7854= :var cp=3D434 :var r=3D0.05 >> ?tha -? (tha - thi) * exp((-3.0*a)/(rho*cp*r)) >> #+END_SRC >> >> #+RESULTS: >> | 19 | Expected a number | >> >> This behaviour has been reported also in SO >> >> http://stackoverflow.com/questions/9559221/simple-math-results-in-an-ema= cs-org-mode-file-with-babel >> > > The calc internals are truly perplexing. In fact, passing floating > point numbers does work as long as division is preformed (see below). > When division and floating point numbers are both present, calc inserts > a ' into its internal representation. Striping this quote out manually > allows the calculation to proceed. The attached patch does this > stripping, resulting the in the change of behavior shown below. > > I suspect that the ' is inserted for some valid reason, so I wouldn't > recommend actually applying this patch to Org-mode unless/until someone > who is familiar with calc can review it. > Looking more closely at the previous behavior (which does remove the ' in some cases), as compared to the patched behavior (which removes the ' in all cases) I have applied this patch after all. It is simpler than the previous behavior, and there is at least one case where it is known to work and the previous behavior is not known to work. Best, --=20 Eric Schulte http://cs.unm.edu/~eschulte