emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Slashes inserted into Common Lisp code evaluation results


From: Nathan Van Ymeren
Subject: Slashes inserted into Common Lisp code evaluation results
Date: Mon, 1 May 2023 23:18:08 -0700

Hi all,

For my studies I’ve been using org as a superior form of jupyter notebook, and 
I do my assignments and whatnot using code blocks for computation.  My 
preferred language these days is Common Lisp, using the SBCL implementation.  
Whereas languages like python default to using IEEE double-width floats, in 
Common Lisp the default type for a value like “1.0872” is a single-width float 
which sometimes introduces precision errors when computing many decimal places.

In Common Lisp (and probably in elisp too, but I don’t speak that dialect so 
idk) you can specify that a number should use double-precision floats by 
appending “d0” to the end, so for example 1.0872d0.

Here’s my problem:

When I specify double width floats, they appear with slashes embedded in the 
RESULTS blocks, like so:

#+begin_src lisp
  (+ 1 0.0002d0)
#+end_src

#+RESULTS:
: 1\.0002d0

Compare that to a single-precision float:

#+begin_src lisp
  (+ 1 0.0002)
#+end_src

#+RESULTS:
: 1.0002

What I’d like to make clear at this point is that *this is not how things look 
in the lisp interpreter*.  For example here’s a transcript of me doing this 
same thing, but not in org:

CL-USER> (+ 1 0.0002d0)
1.0002d0 (100.02d0%)

CL-USER> (+ 1 0.0002)
1.0002 (100.020004%)
CL-USER> 

You can see there’s no slash being emitted, so something in the plumbing 
between SBCL and org is inserting the slash.  I’m running org version 9.7_pre 
built from straight.el on an M-series MacBook Pro, though the same behaviour 
was present in the 9.x release I upgraded from.

Is this a bug?  If not, how do I suppress this behaviour?

Nate


reply via email to

[Prev in Thread] Current Thread [Next in Thread]