[Prev][Next][Index][Thread]
bugs in d2c ratio.dylan
-
To: info-dylan@ai.mit.edu
-
Subject: bugs in d2c ratio.dylan
-
From: Bruce Hoult <bruce@hoult.org>
-
Date: Wed, 19 Dec 2001 01:15:02 -0500 (EST)
-
Organization: TelstraSaturn
-
References: <9vgtl8$6un$1@newsmaster.cc.columbia.edu> <9oVS7.8609$OY3.150806@news3.calgary.shaw.ca> <slrna1q8eu.hf0.Gareth.McCaughan@g.local> <bruce-172C16.22054717122001@news.paradise.net.nz> <bruce-BBDC20.01535118122001@news.paradise.net.nz> <m3sna95e49.fsf@mumonkan.sunstarsys.com> <bruce-9BF494.18055118122001@news.paradise.net.nz> <bruce-E1F709.18164918122001@news.paradise.net.nz> <bruce-A1B725.19193918122001@news.paradise.net.nz> <864rmp6jcu.fsf@raw.grenland.fast.no> <bruce-9AA950.22134718122001@news.paradise.net.nz> <86zo4g6d8r.fsf@raw.grenland.fast.no> <bruce-6B6201.04233919122001@news.paradise.net.nz> <mu9n10f4z5c.fsf@cx281057-c.irvn1.occa.home.com> <bruce-9893CE.17415219122001@news.paradise.net.nz>
-
User-Agent: MT-NewsWatcher/3.0 (PPC)
-
Xref: traf.lcs.mit.edu comp.lang.dylan:13844
In article <bruce-9893CE.17415219122001@news.paradise.net.nz>, Bruce
Hoult <bruce@hoult.org> wrote:
> In article <mu9n10f4z5c.fsf@cx281057-c.irvn1.occa.home.com>,
> housel@home.com (Peter S. Housel) wrote:
>
> > > Unfortunately, since Gwydion doesn't have fractions I needed another
> > > 47
> > > lines of support code. Well I guess I'll put a cleaned up and more
> > > complete version into the Gwydion libraries sometime soon, in which
> > > case
> > > Gwydion *will* support fractions... :-)
> >
> > It has them already. See src/d2c/runtime/dylan/ratio.dylan for the
> > implementation.
>
> Oops! So it does!
>
> Turns out that:
>
> - it uses bignums, not machine integers. We'll see how fast those are...
>
> - you have to import it from the Extensions module, it's not in the
> normal Common-Dylan.
>
> - you need to explicitly create a ratio, then contagion takes hold after
> that. Normal division will never give you one.
>
> - equal-hash(<ratio>) isn't defined so I can't use them in a hash table.
>
> A few minutes work ahead to use this...
Well, it's going to be far more than a "few minutes". Turns out
ratio.dylan is buggy.
On the nineNines problem it fails because it tries to do something with
a fraction equal to 0/0. This is generated first by (0/1) / (171/1),
which should produce 0/1 but produces 0/0.
It turns out that ratio(0/171) produces 0/0 !!!!
And, worse, so do:
0/129
0/131
0/133
0/135
0/137
But it's not just odd denominators. It is odd denominators and only odd
denominators until 0/255, but then you get:
0/258
0/259
0/262
0/263
0/266
0/267
etc. 2 good, 2 bad. Until 0/510, 0/511. Then it's 512,513,514 OK,
515,516,517,519 bad, 3 good, 5 bad etc. Then at 768 it changes to 4
good, 4 bad.
I'm baffled at the moment. Obviously related to patterns in the lower
bits, but how?
aaaarrrrggghhhh!
I think the problem has to be in either truncate/(<extended-integer>,
<extended-integer>) or gcd(<extended-integer>, <extended-integer>).
It's OK .. it's under control. Just venting :-) Did no one ever test
this stuff?
-- Bruce