From: <tomas@tuxteam.de>
To: help-gnu-emacs@gnu.org
Subject: Re: 1.75 -> 1-3/4
Date: Tue, 5 Jun 2018 15:39:10 +0200 [thread overview]
Message-ID: <20180605133910.GG28097@tuxteam.de> (raw)
In-Reply-To: <87a7s9bcdc.fsf@iki.fi>
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On Tue, Jun 05, 2018 at 04:18:23PM +0300, Teemu Likonen wrote:
> Emanuel Berg [2018-06-05 15:01:33+02] wrote:
>
> > Did anyone do the equivalent of this ("ths" zsh below) in Elisp or any
> > other Lisp?
>
> Common Lisp has RATIONAL and RATIONALIZE functions which convert real
> numbers to rational numbers. See the specification:
>
> http://www.lispworks.com/documentation/HyperSpec/Body/f_ration.htm
>
> "Decimals" library for Common Lisp can parse a decimal number string and
> convert it to a rational number. See function PARSE-DECIMAL-NUMBER:
>
> https://github.com/tlikonen/cl-decimals
GNU Guile can do this too:
scheme@(guile-user)> (inexact->exact 1.3333)
$7 = 3002324691586541/2251799813685248
(yikes ;-) but...
scheme@(guile-user)> (rationalize (inexact->exact 1.3333) 1/1000)
$10 = 4/3
(ah, better). Note that the second argument to rationalize *has* to
be a fraction, otherwise the result will be inexact (i.e. a float).
As to Emacs lisp... natively not. But there seems to be a package [1],
and good ol' calc can deal with rationals too.
Now if we had Guile Emacs (I know, I know).
Cheers
[1] https://www.emacswiki.org/emacs/RationalNumber
- -- tomás
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)
iEYEARECAAYFAlsWkn4ACgkQBcgs9XrR2kYFcACfd5vldWofHzr3AvmZbeQqE+9r
1E0An0xTK5IRXElTyHWNwWQ4mzsQfRG2
=mbKJ
-----END PGP SIGNATURE-----
next prev parent reply other threads:[~2018-06-05 13:39 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-05 13:01 1.75 -> 1-3/4 Emanuel Berg
2018-06-05 13:18 ` Teemu Likonen
2018-06-05 13:39 ` tomas [this message]
2018-06-05 13:49 ` tomas
2018-06-05 14:12 ` Teemu Likonen
[not found] ` <mailman.1205.1528205966.1292.help-gnu-emacs@gnu.org>
2018-06-05 15:30 ` Emanuel Berg
2018-06-05 17:00 ` tomas
[not found] ` <mailman.1245.1528218012.1292.help-gnu-emacs@gnu.org>
2018-06-05 18:08 ` Emanuel Berg
2018-06-05 15:25 ` Marko Vojinovic
[not found] ` <mailman.1238.1528215089.1292.help-gnu-emacs@gnu.org>
2018-06-05 18:06 ` Emanuel Berg
[not found] ` <mailman.1199.1528204714.1292.help-gnu-emacs@gnu.org>
2018-06-05 18:54 ` Emanuel Berg
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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180605133910.GG28097@tuxteam.de \
--to=tomas@tuxteam.de \
--cc=help-gnu-emacs@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 external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.