emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nathan Van Ymeren <n@0x85.org>
To: emacs-orgmode@gnu.org
Subject: Slashes inserted into Common Lisp code evaluation results
Date: Mon, 1 May 2023 23:18:08 -0700	[thread overview]
Message-ID: <92ED44D9-830A-43C3-BD4D-64A57354561E@0x85.org> (raw)

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	other threads:[~2023-05-02  6:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-02  6:18 Nathan Van Ymeren [this message]
2023-05-02 10:52 ` Slashes inserted into Common Lisp code evaluation results gerard.vermeulen
2023-05-03  6:00   ` Nathan Van Ymeren
2023-05-03  7:14     ` gerard.vermeulen
2023-05-03  7:45       ` Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=92ED44D9-830A-43C3-BD4D-64A57354561E@0x85.org \
    --to=n@0x85.org \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).