From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Newsgroups: gmane.emacs.help Subject: Re: 1.75 -> 1-3/4 Date: Tue, 5 Jun 2018 15:39:10 +0200 Message-ID: <20180605133910.GG28097@tuxteam.de> References: <86lgbt4cb6.fsf@zoho.com> <87a7s9bcdc.fsf@iki.fi> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; x-action=pgp-signed Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1528205888 31651 195.159.176.226 (5 Jun 2018 13:38:08 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Tue, 5 Jun 2018 13:38:08 +0000 (UTC) User-Agent: Mutt/1.5.21 (2010-09-15) To: help-gnu-emacs@gnu.org Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Tue Jun 05 15:38:04 2018 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1fQCA0-00088G-0J for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 15:38:04 +0200 Original-Received: from localhost ([::1]:46799 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCC7-0002fG-1u for geh-help-gnu-emacs@m.gmane.org; Tue, 05 Jun 2018 09:40:15 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fQCBH-0002bu-Pa for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 09:39:25 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fQCBE-0007xu-0G for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 09:39:23 -0400 Original-Received: from mail.tuxteam.de ([5.199.139.25]:52845) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fQCBD-0007uF-Gi for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 09:39:19 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Transfer-Encoding:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=ohefYBuifUkUYKCJLCRBbvA+q5rxbOzba296tD9l/7c=; b=JUY0hw/S4Jb+tBjVyGnku/h3uU6GxEAwENeZ0dXnB/aplkZpc1Oram1zIKyZhs7CZz7RskDf+mDYKbdb72Ko+wLsxSQcGWitYRFMG+KvoBv4KSEXF9BGQqj2PRh8SpEdxtr+mQRZgbQcLfGmg4WKcaxdKrX1IO0CnNGWWMooFfuQ7Ao9pjX4YTzrbL+Yd+PI04DKOKg+4oPUQYB9bu2IljmuTRxaZ6t8Ztv4yT26+YNwVSXkBRqlDh5IfDkL8lSJRd/c6vyDuZeiK0XpIBeh5zhuK3qTXjlwHAHz0M40EVdwaIku2rfvp3woOJ51vhSBZc4yzomvzSCT0Y0rTL3ruQ==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1fQCB4-0001I0-F7 for help-gnu-emacs@gnu.org; Tue, 05 Jun 2018 15:39:10 +0200 In-Reply-To: <87a7s9bcdc.fsf@iki.fi> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 5.199.139.25 X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.org gmane.emacs.help:116965 Archived-At: -----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-----