## `numlib::decimal` -- infinite representation of rational numbers

#### Introduction

`numlib::decimal``(q)` computes the decimal expansion of a rational number `q`.

#### Call(s)

`numlib::decimal(q)`

#### Parameters

`q` | - | nonnegative rational number

#### Returns

`numlib::decimal``(q)` returns an expression sequence consisting of nonnegative integers or an expression sequence consisting of nonnegative integers and terminated by a list of nonnegative integers.

#### Details

- If `q` is a nonnegative rational number whose decimal expansion is finite, then `numlib::decimal``(q)` returns the expression sequence starting with the integral part of `q` and followed by the digits after the decimal point.
- If `q` is a nonnegative rational number whose decimal expansion is infinite, then `numlib::decimal``(q)` returns the expression sequence starting with the integral part of `q`, followed by the digits of the pre-period and terminated with a list, containing the digits of a minimal period.
- `numlib::decimal` returns an error if the argument is a number but not a rational number .

#### Example 1

Computing the decimal expansion of :

    >> numlib::decimal(1999)

                                       1999

#### Example 2

Computing the (finite) decimal expansion of :

    >> numlib::decimal(52187/78125)

                              0, 6, 6, 7, 9, 9, 3, 6

#### Example 3

Computing the (infinite) decimal expansion of :

    >> numlib::decimal(111/7)

                              15, [8, 5, 7, 1, 4, 2]

#### Example 4

Computing the (infinite) decimal expansion of :

    >> numlib::decimal(37/28)

                            1, 3, 2, [1, 4, 2, 8, 5, 7]

#### Changes

- no changes

Do you have questions or comments?
Copyright © SciFace Software GmbH & Co. KG 2000