This is a live mirror of the Perl 5 development currently hosted at
https://github.com/perl/perl5
https://perl5.git.perl.org
/
perl5.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Re: RFC: bigint et. al exporting PI method? [PATCH]
[perl5.git]
/
lib
/
bigrat.pm
diff --git
a/lib/bigrat.pm
b/lib/bigrat.pm
index
a4de1d6
..
e185d4f
100644
(file)
--- a/
lib/bigrat.pm
+++ b/
lib/bigrat.pm
@@
-4,7
+4,7
@@
use 5.006002;
$VERSION = '0.22';
require Exporter;
@ISA = qw( bigint );
$VERSION = '0.22';
require Exporter;
@ISA = qw( bigint );
-@EXPORT_OK = qw( );
+@EXPORT_OK = qw(
PI e
);
@EXPORT = qw( inf NaN );
use strict;
@EXPORT = qw( inf NaN );
use strict;
@@
-158,7
+158,7
@@
sub import
splice @a, $j, 1; $j --;
$oct = \&bigint::_oct_global;
}
splice @a, $j, 1; $j --;
$oct = \&bigint::_oct_global;
}
- els
e
+ els
if ($_[$i] !~ /^(PI|e)\z/)
{
die ("unknown option $_[$i]");
}
{
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__
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.
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
=item upgrade()
Return the class that numbers are upgraded to, is in fact returning