diff options
author | Tels <nospam-abuse@bloodgate.com> | 2007-06-26 22:56:45 +0200 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@gmail.com> | 2007-06-27 12:57:52 +0000 |
commit | fade31f0d958af49245e9d5d2d39ab5492d90d94 (patch) | |
tree | 95738216b73e942e33eb7e0dd719212b6bdb78c2 /lib/bigrat.pm | |
parent | 30afc38d44f16307c535215ac91b9b6259f70b14 (diff) | |
download | perl-fade31f0d958af49245e9d5d2d39ab5492d90d94.tar.gz |
Re: RFC: bigint et. al exporting PI method? [PATCH]
Message-Id: <200706262056.47311@bloodgate.com>
p4raw-id: //depot/perl@31479
Diffstat (limited to 'lib/bigrat.pm')
-rw-r--r-- | lib/bigrat.pm | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/bigrat.pm b/lib/bigrat.pm index a4de1d68f5..e185d4f0bc 100644 --- a/lib/bigrat.pm +++ b/lib/bigrat.pm @@ -4,7 +4,7 @@ use 5.006002; $VERSION = '0.22'; require Exporter; @ISA = qw( bigint ); -@EXPORT_OK = qw( ); +@EXPORT_OK = qw( PI e ); @EXPORT = qw( inf NaN ); use strict; @@ -158,7 +158,7 @@ sub import splice @a, $j, 1; $j --; $oct = \&bigint::_oct_global; } - else + elsif ($_[$i] !~ /^(PI|e)\z/) { die ("unknown option $_[$i]"); } @@ -226,6 +226,9 @@ sub import } } +sub PI { local $Math::BigFloat::upgrade = undef; Math::BigFloat::bpi(@_); } +sub e { local $Math::BigFloat::upgrade = undef; Math::BigFloat->bone()->bexp(@_); } + 1; __END__ @@ -329,6 +332,14 @@ handle bareword C<inf> properly. A shortcut to return Math::BigInt->bnan(). Useful because Perl does not always handle bareword C<NaN> properly. +=item e() + +Returns Euler's number C<e>, aka exp(1), to the given number of digits. + +=item PI() + +Returns PI to the given number of digits. + =item upgrade() Return the class that numbers are upgraded to, is in fact returning |