From unknown Sat Jun 21 12:13:54 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14905: rationalize not returning the simplest rational Resent-From: =?UTF-8?Q?G=C3=B6ran?= Weinholt Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Fri, 19 Jul 2013 11:26:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14905 X-GNU-PR-Package: guile X-GNU-PR-Keywords: To: 14905@debbugs.gnu.org X-Debbugs-Original-To: bug-guile@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.137423310927780 (code B ref -1); Fri, 19 Jul 2013 11:26:01 +0000 Received: (at submit) by debbugs.gnu.org; 19 Jul 2013 11:25:09 +0000 Received: from localhost ([127.0.0.1]:36913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V08o9-0007Dy-Bp for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43563) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V08o6-0007DT-B5 for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08nz-0001yg-Pg for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-99.2 required=5.0 tests=BAYES_50,T_DKIM_INVALID, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08nz-0001yR-KY for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:24:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08nw-00072D-MU for bug-guile@gnu.org; Fri, 19 Jul 2013 07:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08iE-0007up-Mq for bug-guile@gnu.org; Fri, 19 Jul 2013 07:19:07 -0400 Received: from iustitia.weinholt.se ([2a02:28f0:0:a::7dce:e5a8]:36165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08iE-0007qb-9i for bug-guile@gnu.org; Fri, 19 Jul 2013 07:19:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se; s=iustitia2012; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=zhHgLcl6SGeDehNSgrQ/5bSYkciegM6T0/kjCjgmcfg=; b=clL7tB+VjT8sFs9WJFFHf6lwdmXHRdYCedtye5ufcNZve3PGxFvub+R1yE8Huyir9DtpV6Pyqf91WUF1Z2WWCSwQ7NopNL4ZUdFuVfIJrwobU0oudSm6FKliLcMJL9A8KKk4ARyzgEyvq5OgIe6qjwJMCeG0B01UC1WZOgUV2BxMtySqMKMcEomiEDKaNmodmZ5ZkFJXf9cA2u4SlwfKYmKEFci+binV0G9OAtvZClxBL9BZS8A6CyjYFwD2pwqB1ymL+bXESt9EdcKyFGa9NSJvRzhjReUGm6thisvJBKcMTDBA5UTA8V10nJwN171R90bJbfrSvGUSL/KQicWSOA==; Received: from uucp by iustitia.weinholt.se with local-bsmtp (Exim 4.72) (envelope-from ) id 1V08i6-0002vN-Er; Fri, 19 Jul 2013 13:18:54 +0200 Received: from weinholt by industria with local (Exim 4.80) (envelope-from ) id 1V08hz-0001rv-9t; Fri, 19 Jul 2013 13:18:47 +0200 X-Hashcash: 1:20:130719:bug-guile@gnu.org::iZc0Aau6GotcKHCF:000000000000000000000000000000000000000000009bMv From: =?UTF-8?Q?G=C3=B6ran?= Weinholt Date: Fri, 19 Jul 2013 13:18:41 +0200 Message-ID: <87ehaun6ge.fsf@industria.weinholt.se> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.3 (---) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello schemers, the procedure (rationalize x1 x2) from (rnrs) takes a number x1 and returns the simplest rational that doesn't differ from x1 by more than x2. The implementation in guile has this behavior: scheme@(guile-user)> (rationalize #e-0.67 1/4) $1 =3D -2/3 The problem here is that -1/2 is simpler than -2/3 (since 1<2 and 2<3) and it also doesn't differ from #e-0.67 by more than 1/4 (even though the difference is larger than for -2/3, it is still less than 1/4). So the result from the expression above should be -1/2. Tested with Guile 2.0.9.40-824b-dirty. Regards, =2D-=20 G=C3=B6ran Weinholt "On your own and though you feel alone you are alive. Don't you know it's just another day." -- You Are Alive, Fragma --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCgAGBQJR6SCSAAoJEOM+YaLpuMOiMLMP/j5/BOgsTbACjvjjrOJwhhmg zdoRNZjNgsYIjYPoGakVEjwtMhXe8BHYENtVesFJEUyWS0uCiq9z2Zn3PIAZtoIe z8ctfib+bE6E89r7ol2zA7eZQTAeBevzyC8D6Oesko7lOvMOwADCScrbPpMCVNqi JebYRZiXGysRjIjfoG/itxQ/SVx+cmOXjGknHTtrf92o1MKOx5iQelks+D1dhvSC X3fnqhZ/Q71Y2uY/NajjOEsTptGQvrFDe9GI3PDS3HvjxHFjhwpG8Eipwgaeo/I1 XsWVBLDo5+zTHnXppxs2fijw8SeNhISKSOMPmdiWELBBRI4kQuLlBanmG98FSdY6 q+P9XDeutCq5CZpT5PLDET7INEgXP2GJ6/SShNcAlKrtIYUS/aj8Mw21+ocdB8yf aeDVDdxTY4nL98QdbpLkJvQFuQmNu0N1yCdOUikHAB0jlPFT7pcedH8/83fSqTL9 +Nkv6IH2s6M3dWAbo/HlUyQ5hxSEinFjXDiBQjU/ooj2mMgyiquwe8+5YZ9q+rGG KVoB5DSOiw0MEJ2dRCI1ZmMS5SZvtEZbGgQt62K68icGyNBFGq7TeG9Rmxehr7eM esS2YaguNLJ+faXnLyS8Lmt8lDRS2i2DPmvHfX07Rb0VRETfmvXACLP7nmGzLcZZ WVHbEA831Z1yHx/kgL/4 =Q1wv -----END PGP SIGNATURE----- --=-=-=-- From unknown Sat Jun 21 12:13:54 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: =?UTF-8?Q?G=C3=B6ran?= Weinholt Subject: bug#14905: closed (Re: bug#14905: rationalize not returning the simplest rational) Message-ID: References: <87ob9w9o70.fsf@tines.lan> <87ehaun6ge.fsf@industria.weinholt.se> X-Gnu-PR-Message: they-closed 14905 X-Gnu-PR-Package: guile Reply-To: 14905@debbugs.gnu.org Date: Sun, 21 Jul 2013 10:57:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1374404222-16985-1" This is a multi-part message in MIME format... ------------=_1374404222-16985-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14905: rationalize not returning the simplest rational which was filed against the guile package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14905@debbugs.gnu.org. --=20 14905: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14905 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1374404222-16985-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 14905-done) by debbugs.gnu.org; 21 Jul 2013 10:56:23 +0000 Received: from localhost ([127.0.0.1]:40653 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V0rJO-0004LU-MG for submit@debbugs.gnu.org; Sun, 21 Jul 2013 06:56:22 -0400 Received: from world.peace.net ([96.39.62.75]:60160 ident=hope0) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V0rJK-0004Ky-Ly for 14905-done@debbugs.gnu.org; Sun, 21 Jul 2013 06:56:19 -0400 Received: from c-98-217-64-74.hsd1.ma.comcast.net ([98.217.64.74] helo=tines.lan) by world.peace.net with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1V0rJD-00028b-QD; Sun, 21 Jul 2013 06:56:12 -0400 From: Mark H Weaver To: =?utf-8?Q?G=C3=B6ran?= Weinholt Subject: Re: bug#14905: rationalize not returning the simplest rational References: <87ehaun6ge.fsf@industria.weinholt.se> Date: Sun, 21 Jul 2013 06:56:03 -0400 In-Reply-To: <87ehaun6ge.fsf@industria.weinholt.se> (=?utf-8?Q?=22G=C3=B6r?= =?utf-8?Q?an?= Weinholt"'s message of "Fri, 19 Jul 2013 13:18:41 +0200") Message-ID: <87ob9w9o70.fsf@tines.lan> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 14905-done Cc: 14905-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) G=C3=B6ran Weinholt writes: > the procedure (rationalize x1 x2) from (rnrs) takes a number x1 and > returns the simplest rational that doesn't differ from x1 by more than > x2. The implementation in guile has this behavior: > > scheme@(guile-user)> (rationalize #e-0.67 1/4) > $1 =3D -2/3 > > The problem here is that -1/2 is simpler than -2/3 (since 1<2 and 2<3) > and it also doesn't differ from #e-0.67 by more than 1/4 (even though > the difference is larger than for -2/3, it is still less than 1/4). So > the result from the expression above should be -1/2. Fixed in 620c13e8fc02060e0af8fa38398ee4de745d41e9. Thanks! Mark ------------=_1374404222-16985-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 19 Jul 2013 11:25:09 +0000 Received: from localhost ([127.0.0.1]:36913 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V08o9-0007Dy-Bp for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:09 -0400 Received: from eggs.gnu.org ([208.118.235.92]:43563) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1V08o6-0007DT-B5 for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08nz-0001yg-Pg for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:25:01 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-99.2 required=5.0 tests=BAYES_50,T_DKIM_INVALID, USER_IN_WHITELIST autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:48096) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08nz-0001yR-KY for submit@debbugs.gnu.org; Fri, 19 Jul 2013 07:24:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45253) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08nw-00072D-MU for bug-guile@gnu.org; Fri, 19 Jul 2013 07:24:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V08iE-0007up-Mq for bug-guile@gnu.org; Fri, 19 Jul 2013 07:19:07 -0400 Received: from iustitia.weinholt.se ([2a02:28f0:0:a::7dce:e5a8]:36165) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V08iE-0007qb-9i for bug-guile@gnu.org; Fri, 19 Jul 2013 07:19:02 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=weinholt.se; s=iustitia2012; h=Content-Type:MIME-Version:Message-ID:Date:Subject:To:From; bh=zhHgLcl6SGeDehNSgrQ/5bSYkciegM6T0/kjCjgmcfg=; b=clL7tB+VjT8sFs9WJFFHf6lwdmXHRdYCedtye5ufcNZve3PGxFvub+R1yE8Huyir9DtpV6Pyqf91WUF1Z2WWCSwQ7NopNL4ZUdFuVfIJrwobU0oudSm6FKliLcMJL9A8KKk4ARyzgEyvq5OgIe6qjwJMCeG0B01UC1WZOgUV2BxMtySqMKMcEomiEDKaNmodmZ5ZkFJXf9cA2u4SlwfKYmKEFci+binV0G9OAtvZClxBL9BZS8A6CyjYFwD2pwqB1ymL+bXESt9EdcKyFGa9NSJvRzhjReUGm6thisvJBKcMTDBA5UTA8V10nJwN171R90bJbfrSvGUSL/KQicWSOA==; Received: from uucp by iustitia.weinholt.se with local-bsmtp (Exim 4.72) (envelope-from ) id 1V08i6-0002vN-Er; Fri, 19 Jul 2013 13:18:54 +0200 Received: from weinholt by industria with local (Exim 4.80) (envelope-from ) id 1V08hz-0001rv-9t; Fri, 19 Jul 2013 13:18:47 +0200 X-Hashcash: 1:20:130719:bug-guile@gnu.org::iZc0Aau6GotcKHCF:000000000000000000000000000000000000000000009bMv From: =?utf-8?Q?G=C3=B6ran?= Weinholt To: bug-guile@gnu.org Subject: rationalize not returning the simplest rational Date: Fri, 19 Jul 2013 13:18:41 +0200 Message-ID: <87ehaun6ge.fsf@industria.weinholt.se> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha512; protocol="application/pgp-signature" X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -3.3 (---) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hello schemers, the procedure (rationalize x1 x2) from (rnrs) takes a number x1 and returns the simplest rational that doesn't differ from x1 by more than x2. The implementation in guile has this behavior: scheme@(guile-user)> (rationalize #e-0.67 1/4) $1 =3D -2/3 The problem here is that -1/2 is simpler than -2/3 (since 1<2 and 2<3) and it also doesn't differ from #e-0.67 by more than 1/4 (even though the difference is larger than for -2/3, it is still less than 1/4). So the result from the expression above should be -1/2. Tested with Guile 2.0.9.40-824b-dirty. Regards, =2D-=20 G=C3=B6ran Weinholt "On your own and though you feel alone you are alive. Don't you know it's just another day." -- You Are Alive, Fragma --=-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iQIcBAEBCgAGBQJR6SCSAAoJEOM+YaLpuMOiMLMP/j5/BOgsTbACjvjjrOJwhhmg zdoRNZjNgsYIjYPoGakVEjwtMhXe8BHYENtVesFJEUyWS0uCiq9z2Zn3PIAZtoIe z8ctfib+bE6E89r7ol2zA7eZQTAeBevzyC8D6Oesko7lOvMOwADCScrbPpMCVNqi JebYRZiXGysRjIjfoG/itxQ/SVx+cmOXjGknHTtrf92o1MKOx5iQelks+D1dhvSC X3fnqhZ/Q71Y2uY/NajjOEsTptGQvrFDe9GI3PDS3HvjxHFjhwpG8Eipwgaeo/I1 XsWVBLDo5+zTHnXppxs2fijw8SeNhISKSOMPmdiWELBBRI4kQuLlBanmG98FSdY6 q+P9XDeutCq5CZpT5PLDET7INEgXP2GJ6/SShNcAlKrtIYUS/aj8Mw21+ocdB8yf aeDVDdxTY4nL98QdbpLkJvQFuQmNu0N1yCdOUikHAB0jlPFT7pcedH8/83fSqTL9 +Nkv6IH2s6M3dWAbo/HlUyQ5hxSEinFjXDiBQjU/ooj2mMgyiquwe8+5YZ9q+rGG KVoB5DSOiw0MEJ2dRCI1ZmMS5SZvtEZbGgQt62K68icGyNBFGq7TeG9Rmxehr7eM esS2YaguNLJ+faXnLyS8Lmt8lDRS2i2DPmvHfX07Rb0VRETfmvXACLP7nmGzLcZZ WVHbEA831Z1yHx/kgL/4 =Q1wv -----END PGP SIGNATURE----- --=-=-=-- ------------=_1374404222-16985-1--