* Bug with large fractions @ 2007-01-06 12:05 Ludovic Courtès 2007-01-07 21:43 ` Kevin Ryde 2007-01-09 19:54 ` Ludovic Courtès 0 siblings, 2 replies; 4+ messages in thread From: Ludovic Courtès @ 2007-01-06 12:05 UTC (permalink / raw) Hi, Before I forget about it, I noticed a bug with large fractions. It shows up in the following example: guile> 123123123123123123.12 123123123123123000.0 A quick look at numbers.c:mem2decimal_from_point, and then trying to re-execute the algorithm in there by hand shows that this is not a reader bug: guile> (define x (* 123123123123123123 100)) guile> x 12312312312312312300 guile> (set! x (+ x 12)) guile> x 12312312312312312312 guile> (set! x (/ x 100)) guile> x 3078078078078078078/25 ;; this is wrong! guile> (exact->inexact x) 123123123123123000.0 This is executed on a Guile before Han-Wen's fix, FWIW. Perhaps people more knowledgeable about this will have an idea of what's going wrong. Thanks, Ludovic. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug with large fractions 2007-01-06 12:05 Bug with large fractions Ludovic Courtès @ 2007-01-07 21:43 ` Kevin Ryde 2007-01-09 19:52 ` Ludovic Courtès 2007-01-09 19:54 ` Ludovic Courtès 1 sibling, 1 reply; 4+ messages in thread From: Kevin Ryde @ 2007-01-07 21:43 UTC (permalink / raw) Cc: guile-devel ludo@chbouib.org (Ludovic Courtès) writes: > > guile> 123123123123123123.12 > 123123123123123000.0 I think it's been truncated to 53 bits for the mantissa of a double. (Unless you mean the rounding went the wrong way or something.) _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug with large fractions 2007-01-07 21:43 ` Kevin Ryde @ 2007-01-09 19:52 ` Ludovic Courtès 0 siblings, 0 replies; 4+ messages in thread From: Ludovic Courtès @ 2007-01-09 19:52 UTC (permalink / raw) Hi, Kevin Ryde <user42@zip.com.au> writes: > ludo@chbouib.org (Ludovic Courtès) writes: >> >> guile> 123123123123123123.12 >> 123123123123123000.0 > > I think it's been truncated to 53 bits for the mantissa of a double. Right, the value can't actually fit into a double and reals in Guile _are_ double (it took me a while to get it... ;-)). Thanks, Ludovic. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Bug with large fractions 2007-01-06 12:05 Bug with large fractions Ludovic Courtès 2007-01-07 21:43 ` Kevin Ryde @ 2007-01-09 19:54 ` Ludovic Courtès 1 sibling, 0 replies; 4+ messages in thread From: Ludovic Courtès @ 2007-01-09 19:54 UTC (permalink / raw) Hi, ludo@chbouib.org (Ludovic Courtès) writes: > guile> (define x (* 123123123123123123 100)) > guile> x > 12312312312312312300 > guile> (set! x (+ x 12)) > guile> x > 12312312312312312312 > guile> (set! x (/ x 100)) > guile> x > 3078078078078078078/25 ;; this is wrong! The fraction here is actually correct, only the result of `exact->inexact' is rounded. > guile> (exact->inexact x) > 123123123123123000.0 Thanks, Ludovic. _______________________________________________ Guile-devel mailing list Guile-devel@gnu.org http://lists.gnu.org/mailman/listinfo/guile-devel ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-01-09 19:54 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-01-06 12:05 Bug with large fractions Ludovic Courtès 2007-01-07 21:43 ` Kevin Ryde 2007-01-09 19:52 ` Ludovic Courtès 2007-01-09 19:54 ` Ludovic Courtès
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).