Decimal ExpansionΒΆ

All rationals have repeating decimal expansions. Operations to access the individual digits of a decimal expansion can be obtained by converting the value to RadixExpansion(10).

The operation decimal is used to create this expansion of type DecimalExpansion.

r := decimal(22/7)
    ______
  3.142857
                    Type: DecimalExpansion

Arithmetic is exact.

r + decimal(6/7)
 4
                    Type: DecimalExpansion

The period of the expansion can be short or long ...

[decimal(1/i) for i in 350..354]
      ______    ______         __    ________________________________
 [0.00285714, 0.002849, 0.0028409, 0.00283286118980169971671388101983,
     __________________________________________________________
  0.00282485875706214689265536723163841807909604519774011299435]
                    Type: List DecimalExpansion

or very long.

decimal(1/2049)
   _______________________________________________________________________
 0.00048804294777940458760370912640312347486578818936066373840897999023914
   _____________________________________________________________________
   104441190824792581747193753050268423621278672523182040019521717911176
   _____________________________________________________________________
   183504148365056124938994631527574426549536359199609565641776476329917
   _____________________________________________________________________
   032698877501220107369448511469009272816007808687164470473401659346022
   _______________________________________________________________
   449975597852611029770619814543679843826256710590531966813079551
                   Type: DecimalExpansion

These numbers are bona fide algebraic objects.

p := decimal(1/4)*x**2 + decimal(2/3)*x + decimal(4/9)
      2     _      _
 0.25x  + 0.6x + 0.4
                   Type: Polynomial DecimalExpansion

q := differentiate(p, x)
          _
 0.5x + 0.6
                   Type: Polynomial DecimalExpansion

g := gcd(p, q)
       _
 x + 1.3
                   Type: Polynomial DecimalExpansion

See Also:

  • )help RadixExpansion
  • )help BinaryExpansion
  • )help HexadecimalExpansion
  • )show DecimalExpansion

Table Of Contents

This Page