The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Math::NumSeq::FractionDigits -- the digits of a fraction p/q

SYNOPSIS

 use Math::NumSeq::FractionDigits;
 my $seq = Math::NumSeq::FractionDigits->new (fraction => '2/11');
 my ($i, $value) = $seq->next;

DESCRIPTION

The sequence of digits which are a given fraction. For example 1/7 in decimal, being 0.14285714...

    1, 4, 2, 8, 5, 7, 1, 4, etc

The digits are always a repeating sequence of length no more than den-1. In fact if you want to cook up a repeating sequence a,b,c,a,b,c,etc then the fraction is abc/999. In a base other than decimal the "9" is radix-1, ie. the highest digit.

FUNCTIONS

See "FUNCTIONS" in Math::NumSeq for behaviour common to all sequence classes.

$seq = Math::NumSeq::FractionDigits->new (fraction => $f)
$seq = Math::NumSeq::FractionDigits->new (fraction => $f, radix => $r)

Create and return a new sequence object giving the digits of $f. $f is a string "num/den", or a decimal "xx.yy",

    2/29
    29.125
    1.5/3.25

The default sequence values are decimal digits, or the radix parameter can select another base. (But the fraction parameter is still decimal.)

If the numerator or denominator of the fraction is bigger than fits Perl integer calculations then Math::BigInt is used automatically.

SEE ALSO

Math::NumSeq, Math::NumSeq::SqrtDigits

HOME PAGE

http://user42.tuxfamily.org/math-numseq/index.html

LICENSE

Copyright 2010, 2011, 2012 Kevin Ryde

Math-NumSeq is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

Math-NumSeq is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Math-NumSeq. If not, see <http://www.gnu.org/licenses/>.