This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Bump Safe's VERSION to 2.28
[perl5.git] / dist / Math-BigInt-FastCalc / FastCalc.pm
CommitLineData
062a4e99
T
1package Math::BigInt::FastCalc;
2
08a3f4a9 3use 5.006;
062a4e99
T
4use strict;
5# use warnings; # dont use warnings for older Perls
6
7use DynaLoader;
8use Math::BigInt::Calc;
9
10use vars qw/@ISA $VERSION $BASE $BASE_LEN/;
11
12@ISA = qw(DynaLoader);
13
49f8dfb6 14$VERSION = '0.21';
062a4e99
T
15
16bootstrap Math::BigInt::FastCalc $VERSION;
17
18##############################################################################
19# global constants, flags and accessory
20
21# announce that we are compatible with MBI v1.70 and up
22sub api_version () { 1; }
23
24BEGIN
25 {
26 # use Calc to override the methods that we do not provide in XS
27
28 for my $method (qw/
5ed38b1a 29 str
062a4e99
T
30 add sub mul div
31 rsft lsft
32 mod modpow modinv
33 gcd
5ed38b1a 34 pow root sqrt log_int fac nok
062a4e99 35 digit check
7b29e1e6 36 from_hex from_bin from_oct as_hex as_bin as_oct
08a3f4a9 37 zeros base_len
062a4e99 38 xor or and
c039cd6f 39 alen 1ex
062a4e99
T
40 /)
41 {
42 no strict 'refs';
43 *{'Math::BigInt::FastCalc::_' . $method} = \&{'Math::BigInt::Calc::_' . $method};
44 }
45 my ($AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL);
46
47 # store BASE_LEN and BASE to later pass it to XS code
48 ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL, $BASE) =
49 Math::BigInt::Calc::_base_len();
50
51 }
52
53sub import
54 {
55 _set_XS_BASE($BASE, $BASE_LEN);
56 }
57
58##############################################################################
59##############################################################################
60
611;
62__END__
206957a7 63=pod
062a4e99
T
64
65=head1 NAME
66
67Math::BigInt::FastCalc - Math::BigInt::Calc with some XS for more speed
68
69=head1 SYNOPSIS
70
71Provides support for big integer calculations. Not intended to be used by
72other modules. Other modules which sport the same functions can also be used
73to support Math::BigInt, like L<Math::BigInt::GMP> or L<Math::BigInt::Pari>.
74
75=head1 DESCRIPTION
76
77In order to allow for multiple big integer libraries, Math::BigInt was
78rewritten to use library modules for core math routines. Any module which
79follows the same API as this can be used instead by using the following:
80
81 use Math::BigInt lib => 'libname';
82
83'libname' is either the long name ('Math::BigInt::Pari'), or only the short
84version like 'Pari'. To use this library:
85
86 use Math::BigInt lib => 'FastCalc';
87
88Note that from L<Math::BigInt> v1.76 onwards, FastCalc will be loaded
89automatically, if possible.
90
91=head1 STORAGE
92
93FastCalc works exactly like Calc, in stores the numbers in decimal form,
94chopped into parts.
95
96=head1 METHODS
97
98The following functions are now implemented in FastCalc.xs:
99
100 _is_odd _is_even _is_one _is_zero
101 _is_two _is_ten
102 _zero _one _two _ten
103 _acmp _len _num
104 _inc _dec
105 __strip_zeros _copy
106
107=head1 LICENSE
108
109This program is free software; you may redistribute it and/or modify it under
110the same terms as Perl itself.
111
112=head1 AUTHORS
113
114Original math code by Mark Biggar, rewritten by Tels L<http://bloodgate.com/>
115in late 2000.
116Seperated from BigInt and shaped API with the help of John Peacock.
117Fixed, sped-up and enhanced by Tels http://bloodgate.com 2001-2003.
7b29e1e6 118Further streamlining (api_version 1 etc.) by Tels 2004-2007.
062a4e99
T
119
120=head1 SEE ALSO
121
c039cd6f 122L<Math::BigInt>, L<Math::BigFloat>,
062a4e99
T
123L<Math::BigInt::GMP>, L<Math::BigInt::FastCalc> and L<Math::BigInt::Pari>.
124
125=cut