This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Reinstate part of #28744 that was accidentally reverted in #30454
[perl5.git] / ext / Math / BigInt / FastCalc / FastCalc.pm
CommitLineData
062a4e99
T
1package Math::BigInt::FastCalc;
2
caa64001 3use 5.006002;
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
6c0b8e73 14$VERSION = '0.12_01';
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/
29 new str
30 add sub mul div
31 rsft lsft
32 mod modpow modinv
33 gcd
34 pow root sqrt log_int fac
35 digit check
7b29e1e6 36 from_hex from_bin from_oct as_hex as_bin as_oct
062a4e99
T
37 zeros length base_len
38 xor or and
39 /)
40 {
41 no strict 'refs';
42 *{'Math::BigInt::FastCalc::_' . $method} = \&{'Math::BigInt::Calc::_' . $method};
43 }
44 my ($AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL);
45
46 # store BASE_LEN and BASE to later pass it to XS code
47 ($BASE_LEN, $AND_BITS, $XOR_BITS, $OR_BITS, $BASE_LEN_SMALL, $MAX_VAL, $BASE) =
48 Math::BigInt::Calc::_base_len();
49
50 }
51
52sub import
53 {
54 _set_XS_BASE($BASE, $BASE_LEN);
55 }
56
57##############################################################################
58##############################################################################
59
601;
61__END__
62
63=head1 NAME
64
65Math::BigInt::FastCalc - Math::BigInt::Calc with some XS for more speed
66
67=head1 SYNOPSIS
68
69Provides support for big integer calculations. Not intended to be used by
70other modules. Other modules which sport the same functions can also be used
71to support Math::BigInt, like L<Math::BigInt::GMP> or L<Math::BigInt::Pari>.
72
73=head1 DESCRIPTION
74
75In order to allow for multiple big integer libraries, Math::BigInt was
76rewritten to use library modules for core math routines. Any module which
77follows the same API as this can be used instead by using the following:
78
79 use Math::BigInt lib => 'libname';
80
81'libname' is either the long name ('Math::BigInt::Pari'), or only the short
82version like 'Pari'. To use this library:
83
84 use Math::BigInt lib => 'FastCalc';
85
86Note that from L<Math::BigInt> v1.76 onwards, FastCalc will be loaded
87automatically, if possible.
88
89=head1 STORAGE
90
91FastCalc works exactly like Calc, in stores the numbers in decimal form,
92chopped into parts.
93
94=head1 METHODS
95
96The following functions are now implemented in FastCalc.xs:
97
98 _is_odd _is_even _is_one _is_zero
99 _is_two _is_ten
100 _zero _one _two _ten
101 _acmp _len _num
102 _inc _dec
103 __strip_zeros _copy
104
105=head1 LICENSE
106
107This program is free software; you may redistribute it and/or modify it under
108the same terms as Perl itself.
109
110=head1 AUTHORS
111
112Original math code by Mark Biggar, rewritten by Tels L<http://bloodgate.com/>
113in late 2000.
114Seperated from BigInt and shaped API with the help of John Peacock.
115Fixed, sped-up and enhanced by Tels http://bloodgate.com 2001-2003.
7b29e1e6 116Further streamlining (api_version 1 etc.) by Tels 2004-2007.
062a4e99
T
117
118=head1 SEE ALSO
119
120L<Math::BigInt>, L<Math::BigFloat>, L<Math::BigInt::BitVect>,
121L<Math::BigInt::GMP>, L<Math::BigInt::FastCalc> and L<Math::BigInt::Pari>.
122
123=cut