GNU bug report logs - #14905
rationalize not returning the simplest rational

Previous Next

Package: guile;

Reported by: Göran Weinholt <goran <at> weinholt.se>

Date: Fri, 19 Jul 2013 11:26:01 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14905 in the body.
You can then email your comments to 14905 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guile <at> gnu.org:
bug#14905; Package guile. (Fri, 19 Jul 2013 11:26:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Göran Weinholt <goran <at> weinholt.se>:
New bug report received and forwarded. Copy sent to bug-guile <at> gnu.org. (Fri, 19 Jul 2013 11:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Göran Weinholt <goran <at> weinholt.se>
To: bug-guile <at> gnu.org
Subject: rationalize not returning the simplest rational
Date: Fri, 19 Jul 2013 13:18:41 +0200
[Message part 1 (text/plain, inline)]
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 = -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,

-- 
Göran Weinholt <goran <at> weinholt.se>
"On your own and though you feel alone you are alive.
Don't you know it's just another day." -- You Are Alive, Fragma
[Message part 2 (application/pgp-signature, inline)]

Reply sent to Mark H Weaver <mhw <at> netris.org>:
You have taken responsibility. (Sun, 21 Jul 2013 10:57:01 GMT) Full text and rfc822 format available.

Notification sent to Göran Weinholt <goran <at> weinholt.se>:
bug acknowledged by developer. (Sun, 21 Jul 2013 10:57:02 GMT) Full text and rfc822 format available.

Message #10 received at 14905-done <at> debbugs.gnu.org (full text, mbox):

From: Mark H Weaver <mhw <at> netris.org>
To: Göran Weinholt <goran <at> weinholt.se>
Cc: 14905-done <at> debbugs.gnu.org
Subject: Re: bug#14905: rationalize not returning the simplest rational
Date: Sun, 21 Jul 2013 06:56:03 -0400
Göran Weinholt <goran <at> weinholt.se> 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 = -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




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 18 Aug 2013 11:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 253 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.