Re: rational to floating point

Joachim Durchholz <joachim_d@gmx.de>
14 Mar 2003 11:21:00 -0500

          From comp.compilers

Related articles
rational to floating point thant@acm.org (Thant Tessman) (2003-03-09)
Re: rational to floating point chase@theworld.com (David Chase) (2003-03-14)
Re: rational to floating point nmm1@cus.cam.ac.uk (2003-03-14)
Re: rational to floating point thant@acm.org (Thant Tessman) (2003-03-14)
Re: rational to floating point joachim_d@gmx.de (Joachim Durchholz) (2003-03-14)
Re: rational to floating point ajo@andrew.cmu.edu (Arthur J. O'Dwyer) (2003-03-14)
Re: rational to floating point gah@ugcs.caltech.edu (Glen Herrmannsfeldt) (2003-03-14)
Re: rational to floating point tmk@netvision.net.il (2003-03-14)
Re: rational to floating point Peter-Lawrence.Montgomery@cwi.nl (2003-03-14)
Re: rational to floating point francis@thibault.org (John Stracke) (2003-03-14)
| List of all articles for this month |
From: Joachim Durchholz <joachim_d@gmx.de>
Newsgroups: comp.compilers
Date: 14 Mar 2003 11:21:00 -0500
Organization: Compilers Central
References: 03-03-035
Keywords: arithmetic
Posted-Date: 14 Mar 2003 11:21:00 EST

Thant Tessman wrote:
>
> The question is: Under what conditions will a rational number produce
> an infinite stream of digits for a given base?


Iff the base and the denominator have the same prime factors. (Prime
factors may be present in different powers.)


gcd won't help, unfortunately.


There's a simpler test though: There's a maximum number of digits for
both the non-repeating and the repeating part of a fraction. I can't
give the exact conditions off the top of my head, but IIRC the maximum
lengths depend on the number of digits in the denominator (as written in
the base, so the base enters as well).


> I think there is no solution to the above equation if the denominator
> of the original rational number and the base contain no prime factors
> in common. And I think that this in turn implies that if and only if
> gcd(d,b) is 1 and 'd' is not 1, then the original rational number can
> only be represented by an infinite stream of digits.


Counterexample: base 10, denominator 15. gcd is 5, but you'll still get
an infinite stream for any numbers that aren't divisible by 3...


HTH
Joachim


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.