RE: repeating decimals

• To: mathgroup at smc.vnet.net
• Subject: [mg29209] RE: [mg29200] repeating decimals
• From: "David Park" <djmp at earthlink.net>
• Date: Mon, 4 Jun 2001 05:30:42 -0400 (EDT)
• Sender: owner-wri-mathgroup at wolfram.com

```Hi Tom,

I wonder if you have checked into the standard package
NumberTheory`ContinuedFractions? If gives exact representations for
repeating decimals and in any base. (The Version 4 packaged has been changed
from the Version 3 package so work with the online documentation if you
don't have an up to date standard packages book.)

Needs["NumberTheory`ContinuedFractions`"]

e1 = PeriodicForm[RealDigits[7/13]]
0.538461 (where the repeating fraction digits are displayed with bars over
them)

This is how the repeating decimal is stored in Mathematica.

FullForm[e1]
PeriodicForm[List[List[List[5, 3, 8, 4, 6, 1]], 0]]

Using PeriodicForm should be better than using N which only gives
approximate results. Of course the students can check that the two results
agree up to the approximation.

NumberForm[N[7/13, 50], DigitBlock -> 6, NumberSeparator -> " "]
0.538461 538461 538461 538461 538461 538461 538461 538461 54

N is used to convert exact numbers to approximate numbers. If the precision
specified is less than or equal to machine precision, then machine precision
is used. Machine precision numbers are displayed with 6 digits (dropping
trailing zeros) unless you change the display in the Option Inspector. Only
if you make the precision greater than machine precision will you always
obtain the full display of digits.

The following does not work because Mathematica has made 7/13. into a
machine precision approximate number as the first step in evaluation. It
doesn't have 30 digits. You have to use the construction I used above.

NumberForm[7/13. , 30,  DigitBlock -> 6, NumberSeparator -> "  "]
0.538461  538461  5385

David Park

> From: Tom De Vries [mailto:tdevries at shop.westworld.ca]
To: mathgroup at smc.vnet.net
>
> Hello!
>
> I am working on a simple notebook to illustrate repeating and terminating
> decimals for a junior high math class.
>
> I know the topic  of representing decimal numbers has been discussed here
> before, but I am still a bit confused....
>
> On my Mac
>
> \$Version
>
> "4.0 for Power Macintosh (July 20, 1999)"
>
> Why does
>
> N[1/2, 10]
>
> give me
>
> 0.5
>
> and why does
>
> N[1/2, 20]
>
> give me
>
> 0.50000000000000000000
>
> why does
>
> NumberForm[7/13. , 15,   DigitBlock -> 6, NumberSeparator -> " "]
>
> give me
>
> 0.538461  538461  539
>
>
> and why does
>
> NumberForm[7/13. , 30,  DigitBlock -> 6, NumberSeparator -> "  "]
>
> 0.538461   538461    5385
>
>
> It seems to me that the number of digits I am asking for is not related to
> what I actually get.  Is there a way to ask Mathematica to represent the
> decimal approximation that would be consistent?
>
>
> Sincerely,
>
> Tom De Vries
>
>
>

```

• Prev by Date: Re: postscript versions of the math1 truetype fonts
• Next by Date: Re: Compound Expressions
• Previous by thread: Re: Repeating decimals
• Next by thread: Classifying by Inequalities???