exiftool-vendored.exe 12.80.0 → 12.82.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -0
- package/bin/exiftool.exe +0 -0
- package/bin/exiftool_files/Changes +44 -0
- package/bin/exiftool_files/Licenses_Strawberry_Perl.zip +0 -0
- package/bin/exiftool_files/README +3 -2
- package/bin/exiftool_files/exiftool.pl +36 -14
- package/bin/exiftool_files/lib/Archive/Zip/Archive.pm +399 -65
- package/bin/exiftool_files/lib/Archive/Zip/DirectoryMember.pm +1 -1
- package/bin/exiftool_files/lib/Archive/Zip/FileMember.pm +1 -1
- package/bin/exiftool_files/lib/Archive/Zip/Member.pm +499 -195
- package/bin/exiftool_files/lib/Archive/Zip/NewFileMember.pm +1 -1
- package/bin/exiftool_files/lib/Archive/Zip/StringMember.pm +2 -2
- package/bin/exiftool_files/lib/Archive/Zip/ZipFileMember.pm +79 -20
- package/bin/exiftool_files/lib/Archive/Zip.pm +179 -29
- package/bin/exiftool_files/lib/AutoLoader.pm +453 -0
- package/bin/exiftool_files/lib/B/Deparse.pm +209 -137
- package/bin/exiftool_files/lib/B.pm +1 -1
- package/bin/exiftool_files/lib/Benchmark.pm +1123 -0
- package/bin/exiftool_files/lib/Class/Struct.pm +2 -2
- package/bin/exiftool_files/lib/Compress/Raw/Bzip2.pm +14 -9
- package/bin/exiftool_files/lib/Compress/Raw/Lzma.pm +982 -0
- package/bin/exiftool_files/lib/Compress/Raw/Zlib.pm +91 -86
- package/bin/exiftool_files/lib/Compress/Zlib.pm +105 -100
- package/bin/exiftool_files/lib/Config.pm +9 -9
- package/bin/exiftool_files/lib/Config_heavy.pl +36 -33
- package/bin/exiftool_files/lib/CryptX.pm +2 -82
- package/bin/exiftool_files/lib/Data/Dumper.pm +2 -2
- package/bin/exiftool_files/lib/Digest/MD5.pm +12 -9
- package/bin/exiftool_files/lib/Digest/Perl/MD5.pm +1 -191
- package/bin/exiftool_files/lib/Digest/base.pm +26 -20
- package/bin/exiftool_files/lib/DynaLoader.pm +7 -4
- package/bin/exiftool_files/lib/Encode.pm +3 -3
- package/bin/exiftool_files/lib/Errno.pm +13 -13
- package/bin/exiftool_files/lib/Exporter/Heavy.pm +2 -2
- package/bin/exiftool_files/lib/Exporter.pm +1 -1
- package/bin/exiftool_files/lib/ExtUtils/Command/MM.pm +323 -0
- package/bin/exiftool_files/lib/ExtUtils/Command.pm +382 -0
- package/bin/exiftool_files/lib/File/Find.pm +1 -1
- package/bin/exiftool_files/lib/File/Glob.pm +1 -8
- package/bin/exiftool_files/lib/File/GlobMapper.pm +2 -2
- package/bin/exiftool_files/lib/File/HomeDir/Darwin/Carbon.pm +2 -40
- package/bin/exiftool_files/lib/File/HomeDir/Darwin/Cocoa.pm +2 -34
- package/bin/exiftool_files/lib/File/HomeDir/Darwin.pm +2 -28
- package/bin/exiftool_files/lib/File/HomeDir/Driver.pm +2 -35
- package/bin/exiftool_files/lib/File/HomeDir/FreeDesktop.pm +2 -62
- package/bin/exiftool_files/lib/File/HomeDir/MacOS9.pm +2 -53
- package/bin/exiftool_files/lib/File/HomeDir/Test.pm +2 -43
- package/bin/exiftool_files/lib/File/HomeDir/Unix.pm +2 -53
- package/bin/exiftool_files/lib/File/HomeDir/Windows.pm +2 -69
- package/bin/exiftool_files/lib/File/HomeDir.pm +5 -416
- package/bin/exiftool_files/lib/File/Path.pm +3 -3
- package/bin/exiftool_files/lib/File/Spec/Win32.pm +2 -2
- package/bin/exiftool_files/lib/File/Temp.pm +70 -35
- package/bin/exiftool_files/lib/File/Which.pm +1 -240
- package/bin/exiftool_files/lib/File/stat.pm +3 -2
- package/bin/exiftool_files/lib/IO/Compress/Adapter/Bzip2.pm +16 -17
- package/bin/exiftool_files/lib/IO/Compress/Adapter/Deflate.pm +19 -20
- package/bin/exiftool_files/lib/IO/Compress/Base/Common.pm +5 -5
- package/bin/exiftool_files/lib/IO/Compress/Base.pm +35 -26
- package/bin/exiftool_files/lib/IO/Compress/Brotli.pm +159 -0
- package/bin/exiftool_files/lib/IO/Compress/Bzip2.pm +50 -25
- package/bin/exiftool_files/lib/IO/Compress/Gzip/Constants.pm +6 -6
- package/bin/exiftool_files/lib/IO/Compress/Gzip.pm +58 -32
- package/bin/exiftool_files/lib/IO/Compress/RawDeflate.pm +63 -38
- package/bin/exiftool_files/lib/IO/Compress/Zlib/Extra.pm +20 -20
- package/bin/exiftool_files/lib/IO/Dir.pm +1 -1
- package/bin/exiftool_files/lib/IO/File.pm +1 -1
- package/bin/exiftool_files/lib/IO/Handle.pm +1 -21
- package/bin/exiftool_files/lib/IO/Pipe.pm +1 -1
- package/bin/exiftool_files/lib/IO/Seekable.pm +1 -1
- package/bin/exiftool_files/lib/IO/Select.pm +16 -2
- package/bin/exiftool_files/lib/IO/Socket/INET.pm +14 -9
- package/bin/exiftool_files/lib/IO/Socket/UNIX.pm +17 -1
- package/bin/exiftool_files/lib/IO/Socket.pm +474 -126
- package/bin/exiftool_files/lib/IO/String.pm +425 -0
- package/bin/exiftool_files/lib/IO/Uncompress/Adapter/Inflate.pm +13 -14
- package/bin/exiftool_files/lib/IO/Uncompress/Base.pm +142 -132
- package/bin/exiftool_files/lib/IO/Uncompress/Brotli.pm +119 -0
- package/bin/exiftool_files/lib/IO/Uncompress/Gunzip.pm +43 -37
- package/bin/exiftool_files/lib/IO/Uncompress/RawInflate.pm +49 -43
- package/bin/exiftool_files/lib/IO.pm +2 -2
- package/bin/exiftool_files/lib/Image/ExifTool/BuildTagLookup.pm +44 -31
- package/bin/exiftool_files/lib/Image/ExifTool/CanonVRD.pm +2 -2
- package/bin/exiftool_files/lib/Image/ExifTool/FujiFilm.pm +20 -7
- package/bin/exiftool_files/lib/Image/ExifTool/GM.pm +543 -0
- package/bin/exiftool_files/lib/Image/ExifTool/Geolocation.pm +332 -149
- package/bin/exiftool_files/lib/Image/ExifTool/Geotag.pm +9 -4
- package/bin/exiftool_files/lib/Image/ExifTool/M2TS.pm +32 -4
- package/bin/exiftool_files/lib/Image/ExifTool/MakerNotes.pm +2 -2
- package/bin/exiftool_files/lib/Image/ExifTool/Microsoft.pm +1 -1
- package/bin/exiftool_files/lib/Image/ExifTool/Nikon.pm +331 -22
- package/bin/exiftool_files/lib/Image/ExifTool/NikonCustom.pm +55 -1
- package/bin/exiftool_files/lib/Image/ExifTool/Olympus.pm +1 -0
- package/bin/exiftool_files/lib/Image/ExifTool/OpenEXR.pm +21 -3
- package/bin/exiftool_files/lib/Image/ExifTool/PNG.pm +3 -3
- package/bin/exiftool_files/lib/Image/ExifTool/QuickTime.pm +40 -24
- package/bin/exiftool_files/lib/Image/ExifTool/QuickTimeStream.pl +61 -30
- package/bin/exiftool_files/lib/Image/ExifTool/README +2 -0
- package/bin/exiftool_files/lib/Image/ExifTool/Sony.pm +1 -1
- package/bin/exiftool_files/lib/Image/ExifTool/TagLookup.pm +4815 -4775
- package/bin/exiftool_files/lib/Image/ExifTool/TagNames.pod +931 -617
- package/bin/exiftool_files/lib/Image/ExifTool/WriteQuickTime.pl +30 -8
- package/bin/exiftool_files/lib/Image/ExifTool/Writer.pl +10 -4
- package/bin/exiftool_files/lib/Image/ExifTool/XMP.pm +4 -2
- package/bin/exiftool_files/lib/Image/ExifTool.pm +77 -41
- package/bin/exiftool_files/lib/Image/ExifTool.pod +24 -11
- package/bin/exiftool_files/lib/List/Util.pm +97 -8
- package/bin/exiftool_files/lib/MIME/Base64.pm +5 -5
- package/bin/exiftool_files/lib/MIME/Charset/_Compat.pm +106 -0
- package/bin/exiftool_files/lib/MIME/Charset.pm +1303 -0
- package/bin/exiftool_files/lib/Math/BigFloat.pm +444 -27
- package/bin/exiftool_files/lib/Math/BigInt/Calc.pm +296 -313
- package/bin/exiftool_files/lib/Math/BigInt/FastCalc.pm +1 -1
- package/bin/exiftool_files/lib/Math/BigInt/GMP.pm +2 -115
- package/bin/exiftool_files/lib/Math/BigInt/LTM.pm +2 -24
- package/bin/exiftool_files/lib/Math/BigInt/Lib.pm +61 -32
- package/bin/exiftool_files/lib/Math/BigInt.pm +292 -107
- package/bin/exiftool_files/lib/POSIX.pm +1 -1
- package/bin/exiftool_files/lib/PerlIO/scalar.pm +41 -0
- package/bin/exiftool_files/lib/PerlIO.pm +397 -0
- package/bin/exiftool_files/lib/Portable/CPAN.pm +94 -94
- package/bin/exiftool_files/lib/Portable/Config.pm +94 -94
- package/bin/exiftool_files/lib/Portable/FileSpec.pm +180 -180
- package/bin/exiftool_files/lib/Portable/HomeDir.pm +110 -110
- package/bin/exiftool_files/lib/Portable/LoadYaml.pm +430 -430
- package/bin/exiftool_files/lib/Portable/minicpan.pm +55 -55
- package/bin/exiftool_files/lib/Portable.pm +246 -320
- package/bin/exiftool_files/lib/Scalar/Util.pm +9 -4
- package/bin/exiftool_files/lib/Socket.pm +16 -12
- package/bin/exiftool_files/lib/Storable.pm +1444 -1441
- package/bin/exiftool_files/lib/TAP/Base.pm +133 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Base.pm +467 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Color.pm +116 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Console/ParallelSession.pm +201 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Console/Session.pm +205 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Console.pm +100 -0
- package/bin/exiftool_files/lib/TAP/Formatter/File/Session.pm +95 -0
- package/bin/exiftool_files/lib/TAP/Formatter/File.pm +56 -0
- package/bin/exiftool_files/lib/TAP/Formatter/Session.pm +220 -0
- package/bin/exiftool_files/lib/TAP/Harness/Beyond.pod +426 -0
- package/bin/exiftool_files/lib/TAP/Harness/Env.pm +215 -0
- package/bin/exiftool_files/lib/TAP/Harness.pm +1054 -0
- package/bin/exiftool_files/lib/TAP/Object.pm +155 -0
- package/bin/exiftool_files/lib/TAP/Parser/Aggregator.pm +414 -0
- package/bin/exiftool_files/lib/TAP/Parser/Grammar.pm +584 -0
- package/bin/exiftool_files/lib/TAP/Parser/Iterator/Array.pm +100 -0
- package/bin/exiftool_files/lib/TAP/Parser/Iterator/Process.pm +378 -0
- package/bin/exiftool_files/lib/TAP/Parser/Iterator/Stream.pm +116 -0
- package/bin/exiftool_files/lib/TAP/Parser/Iterator.pm +162 -0
- package/bin/exiftool_files/lib/TAP/Parser/IteratorFactory.pm +339 -0
- package/bin/exiftool_files/lib/TAP/Parser/Multiplexer.pm +194 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Bailout.pm +62 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Comment.pm +60 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Plan.pm +119 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Pragma.pm +62 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Test.pm +271 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Unknown.pm +48 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/Version.pm +62 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result/YAML.pm +61 -0
- package/bin/exiftool_files/lib/TAP/Parser/Result.pm +297 -0
- package/bin/exiftool_files/lib/TAP/Parser/ResultFactory.pm +183 -0
- package/bin/exiftool_files/lib/TAP/Parser/Scheduler/Job.pm +127 -0
- package/bin/exiftool_files/lib/TAP/Parser/Scheduler/Spinner.pm +61 -0
- package/bin/exiftool_files/lib/TAP/Parser/Scheduler.pm +448 -0
- package/bin/exiftool_files/lib/TAP/Parser/Source.pm +381 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Executable.pm +184 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/File.pm +136 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Handle.pm +124 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/Perl.pm +370 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler/RawTAP.pm +130 -0
- package/bin/exiftool_files/lib/TAP/Parser/SourceHandler.pm +191 -0
- package/bin/exiftool_files/lib/TAP/Parser/YAMLish/Reader.pm +332 -0
- package/bin/exiftool_files/lib/TAP/Parser/YAMLish/Writer.pm +254 -0
- package/bin/exiftool_files/lib/TAP/Parser.pm +1931 -0
- package/bin/exiftool_files/lib/Test/Builder/Formatter.pm +107 -0
- package/bin/exiftool_files/lib/Test/Builder/IO/Scalar.pm +659 -0
- package/bin/exiftool_files/lib/Test/Builder/Module.pm +182 -0
- package/bin/exiftool_files/lib/Test/Builder/Tester/Color.pm +51 -0
- package/bin/exiftool_files/lib/Test/Builder/Tester.pm +675 -0
- package/bin/exiftool_files/lib/Test/Builder/TodoDiag.pm +68 -0
- package/bin/exiftool_files/lib/Test/Builder.pm +2653 -0
- package/bin/exiftool_files/lib/Test/Harness.pm +618 -0
- package/bin/exiftool_files/lib/Test/More.pm +1997 -0
- package/bin/exiftool_files/lib/Test/Simple.pm +220 -0
- package/bin/exiftool_files/lib/Test/Tester/Capture.pm +241 -0
- package/bin/exiftool_files/lib/Test/Tester/CaptureRunner.pm +79 -0
- package/bin/exiftool_files/lib/Test/Tester/Delegate.pm +45 -0
- package/bin/exiftool_files/lib/Test/Tester.pm +695 -0
- package/bin/exiftool_files/lib/Test/Tutorial.pod +618 -0
- package/bin/exiftool_files/lib/Test/use/ok.pm +64 -0
- package/bin/exiftool_files/lib/Text/ParseWords.pm +303 -0
- package/bin/exiftool_files/lib/Tie/StdHandle.pm +2 -2
- package/bin/exiftool_files/lib/Time/HiRes.pm +73 -68
- package/bin/exiftool_files/lib/Time/Local.pm +82 -35
- package/bin/exiftool_files/lib/Time/Piece.pm +19 -4
- package/bin/exiftool_files/lib/Time/Seconds.pm +1 -1
- package/bin/exiftool_files/lib/UNIVERSAL.pm +203 -0
- package/bin/exiftool_files/lib/Unicode/GCString.pm +60 -0
- package/bin/exiftool_files/lib/Unicode/LineBreak/Constants.pm +68 -0
- package/bin/exiftool_files/lib/Unicode/LineBreak.pm +248 -0
- package/bin/exiftool_files/lib/Win32/API/Struct.pm +1 -177
- package/bin/exiftool_files/lib/Win32/API/Type.pm +1 -100
- package/bin/exiftool_files/lib/Win32/API.pm +1 -830
- package/bin/exiftool_files/lib/Win32/FindFile.pm +2 -123
- package/bin/exiftool_files/lib/Win32.pm +213 -89
- package/bin/exiftool_files/lib/Win32API/File.pm +1 -1
- package/bin/exiftool_files/lib/auto/B/B.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Compress/Raw/Bzip2/Bzip2.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Compress/Raw/Lzma/Lzma.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Compress/Raw/Lzma/autosplit.ix +3 -0
- package/bin/exiftool_files/lib/auto/Compress/Raw/Zlib/Zlib.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/CryptX/CryptX.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Cwd/Cwd.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Data/Dumper/Dumper.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Digest/MD5/MD5.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Digest/SHA/SHA.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Encode/Encode.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Fcntl/Fcntl.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/File/Glob/Glob.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/IO/Compress/Brotli/Brotli.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/IO/IO.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/List/Util/Util.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/MIME/Base64/Base64.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Math/BigInt/FastCalc/FastCalc.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Math/BigInt/GMP/GMP.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/POSIX/POSIX.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/PerlIO/scalar/scalar.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Socket/Socket.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Storable/Storable.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Time/HiRes/HiRes.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Time/Piece/Piece.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Unicode/LineBreak/LineBreak.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Win32/API/API.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Win32/FindFile/FindFile.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Win32/Win32.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/Win32API/File/File.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/mro/mro.xs.dll +0 -0
- package/bin/exiftool_files/lib/auto/re/re.xs.dll +0 -0
- package/bin/exiftool_files/lib/feature.pm +49 -17
- package/bin/exiftool_files/lib/mro.pm +4 -20
- package/bin/exiftool_files/lib/overload.pm +15 -15
- package/bin/exiftool_files/lib/parent.pm +10 -2
- package/bin/exiftool_files/lib/re.pm +91 -33
- package/bin/exiftool_files/lib/warnings.pm +17 -6
- package/bin/exiftool_files/libgcc_s_seh-1.dll +0 -0
- package/bin/exiftool_files/liblzma-5__.dll +0 -0
- package/bin/exiftool_files/libstdc++-6.dll +0 -0
- package/bin/exiftool_files/libwinpthread-1.dll +0 -0
- package/bin/exiftool_files/perl.exe +0 -0
- package/bin/exiftool_files/perl532.dll +0 -0
- package/package.json +7 -5
- package/bin/exiftool_files/libgcc_s_dw2-1.dll +0 -0
- package/bin/exiftool_files/perl530.dll +0 -0
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# -*- coding: utf-8-unix -*-
|
|
2
|
+
|
|
1
3
|
package Math::BigInt;
|
|
2
4
|
|
|
3
5
|
#
|
|
@@ -20,14 +22,12 @@ use warnings;
|
|
|
20
22
|
|
|
21
23
|
use Carp qw< carp croak >;
|
|
22
24
|
|
|
23
|
-
our $VERSION = '1.
|
|
25
|
+
our $VERSION = '1.999818';
|
|
24
26
|
|
|
25
27
|
require Exporter;
|
|
26
28
|
our @ISA = qw(Exporter);
|
|
27
29
|
our @EXPORT_OK = qw(objectify bgcd blcm);
|
|
28
30
|
|
|
29
|
-
my $class = "Math::BigInt";
|
|
30
|
-
|
|
31
31
|
# Inside overload, the first arg is always an object. If the original code had
|
|
32
32
|
# it reversed (like $x = 2 * $y), then the third parameter is true.
|
|
33
33
|
# In some cases (like add, $x = $x + 2 is the same as $x = 2 + $x) this makes
|
|
@@ -232,9 +232,7 @@ my $LIB = 'Math::BigInt::Calc'; # module to do the low level math
|
|
|
232
232
|
# default is Calc.pm
|
|
233
233
|
my $IMPORT = 0; # was import() called yet?
|
|
234
234
|
# used to make require work
|
|
235
|
-
my %WARN; # warn only once for low-level libs
|
|
236
235
|
my %CALLBACKS; # callbacks to notify on lib loads
|
|
237
|
-
my $EMU_LIB = 'Math/BigInt/CalcEmu.pm'; # emulate low-level math
|
|
238
236
|
|
|
239
237
|
##############################################################################
|
|
240
238
|
# the old code had $rnd_mode, so we need to support it, too
|
|
@@ -1135,7 +1133,7 @@ sub bpi {
|
|
|
1135
1133
|
if (@_ == 1) {
|
|
1136
1134
|
# called like Math::BigInt::bpi(10);
|
|
1137
1135
|
$n = $self;
|
|
1138
|
-
$self =
|
|
1136
|
+
$self = __PACKAGE__;
|
|
1139
1137
|
}
|
|
1140
1138
|
$self = ref($self) if ref($self);
|
|
1141
1139
|
|
|
@@ -1234,6 +1232,24 @@ sub is_negative {
|
|
|
1234
1232
|
$x->{sign} =~ /^-/ ? 1 : 0; # -inf is negative, but NaN is not
|
|
1235
1233
|
}
|
|
1236
1234
|
|
|
1235
|
+
sub is_non_negative {
|
|
1236
|
+
# Return true if argument is non-negative (>= 0).
|
|
1237
|
+
my ($class, $x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
|
|
1238
|
+
|
|
1239
|
+
return 1 if $x->{sign} =~ /^\+/;
|
|
1240
|
+
return 1 if $x -> is_zero();
|
|
1241
|
+
return 0;
|
|
1242
|
+
}
|
|
1243
|
+
|
|
1244
|
+
sub is_non_positive {
|
|
1245
|
+
# Return true if argument is non-positive (<= 0).
|
|
1246
|
+
my ($class, $x) = ref($_[0]) ? (undef,$_[0]) : objectify(1,@_);
|
|
1247
|
+
|
|
1248
|
+
return 1 if $x->{sign} =~ /^\-/;
|
|
1249
|
+
return 1 if $x -> is_zero();
|
|
1250
|
+
return 0;
|
|
1251
|
+
}
|
|
1252
|
+
|
|
1237
1253
|
sub is_odd {
|
|
1238
1254
|
# return true when arg (BINT or num_str) is odd, false for even
|
|
1239
1255
|
my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_);
|
|
@@ -2354,7 +2370,7 @@ sub bmodpow {
|
|
|
2354
2370
|
$num->{value} = $value;
|
|
2355
2371
|
$num->{sign} = $sign;
|
|
2356
2372
|
|
|
2357
|
-
return $num;
|
|
2373
|
+
return $num -> round(@r);
|
|
2358
2374
|
}
|
|
2359
2375
|
|
|
2360
2376
|
sub bpow {
|
|
@@ -2401,21 +2417,14 @@ sub bpow {
|
|
|
2401
2417
|
|
|
2402
2418
|
$r[3] = $y; # no push!
|
|
2403
2419
|
|
|
2404
|
-
#
|
|
2405
|
-
|
|
2406
|
-
my $new_sign = '+';
|
|
2407
|
-
$new_sign = $y->is_odd() ? '-' : '+' if ($x->{sign} ne '+');
|
|
2420
|
+
# 0 ** -y => ( 1 / (0 ** y)) => 1 / 0 => +inf
|
|
2421
|
+
return $x->binf() if $y->is_negative() && $x->is_zero();
|
|
2408
2422
|
|
|
2409
|
-
# 0 ** -7 => ( 1 / (0 ** 7)) => 1 / 0 => +inf
|
|
2410
|
-
return $x->binf()
|
|
2411
|
-
if $y->{sign} eq '-' && $x->{sign} eq '+' && $LIB->_is_zero($x->{value});
|
|
2412
2423
|
# 1 ** -y => 1 / (1 ** |y|)
|
|
2413
|
-
|
|
2414
|
-
return $x->bnan() if $y->{sign} eq '-' && !$LIB->_is_one($x->{value});
|
|
2424
|
+
return $x->bzero() if $y->is_negative() && !$LIB->_is_one($x->{value});
|
|
2415
2425
|
|
|
2416
2426
|
$x->{value} = $LIB->_pow($x->{value}, $y->{value});
|
|
2417
|
-
$x->{sign}
|
|
2418
|
-
$x->{sign} = '+' if $LIB->_is_zero($y->{value});
|
|
2427
|
+
$x->{sign} = $x->is_negative() && $y->is_odd() ? '-' : '+';
|
|
2419
2428
|
$x->round(@r);
|
|
2420
2429
|
}
|
|
2421
2430
|
|
|
@@ -2483,7 +2492,7 @@ sub blog {
|
|
|
2483
2492
|
return $x;
|
|
2484
2493
|
}
|
|
2485
2494
|
|
|
2486
|
-
my ($rc
|
|
2495
|
+
my ($rc) = $LIB->_log_int($x->{value}, $base->{value});
|
|
2487
2496
|
return $x->bnan() unless defined $rc; # not possible to take log?
|
|
2488
2497
|
$x->{value} = $rc;
|
|
2489
2498
|
$x->round(@r);
|
|
@@ -2602,6 +2611,126 @@ sub bnok {
|
|
|
2602
2611
|
$n->round(@r);
|
|
2603
2612
|
}
|
|
2604
2613
|
|
|
2614
|
+
sub buparrow {
|
|
2615
|
+
my $a = shift;
|
|
2616
|
+
my $y = $a -> uparrow(@_);
|
|
2617
|
+
$a -> {value} = $y -> {value};
|
|
2618
|
+
return $a;
|
|
2619
|
+
}
|
|
2620
|
+
|
|
2621
|
+
sub uparrow {
|
|
2622
|
+
# Knuth's up-arrow notation buparrow(a, n, b)
|
|
2623
|
+
#
|
|
2624
|
+
# The following is a simple, recursive implementation of the up-arrow
|
|
2625
|
+
# notation, just to show the idea. Such implementations cause "Deep
|
|
2626
|
+
# recursion on subroutine ..." warnings, so we use a faster, non-recursive
|
|
2627
|
+
# algorithm below with @_ as a stack.
|
|
2628
|
+
#
|
|
2629
|
+
# sub buparrow {
|
|
2630
|
+
# my ($a, $n, $b) = @_;
|
|
2631
|
+
# return $a ** $b if $n == 1;
|
|
2632
|
+
# return $a * $b if $n == 0;
|
|
2633
|
+
# return 1 if $b == 0;
|
|
2634
|
+
# return buparrow($a, $n - 1, buparrow($a, $n, $b - 1));
|
|
2635
|
+
# }
|
|
2636
|
+
|
|
2637
|
+
my ($a, $b, $n) = @_;
|
|
2638
|
+
my $class = ref $a;
|
|
2639
|
+
croak("a must be non-negative") if $a < 0;
|
|
2640
|
+
croak("n must be non-negative") if $n < 0;
|
|
2641
|
+
croak("b must be non-negative") if $b < 0;
|
|
2642
|
+
|
|
2643
|
+
while (@_ >= 3) {
|
|
2644
|
+
|
|
2645
|
+
# return $a ** $b if $n == 1;
|
|
2646
|
+
|
|
2647
|
+
if ($_[-2] == 1) {
|
|
2648
|
+
my ($a, $n, $b) = splice @_, -3;
|
|
2649
|
+
push @_, $a ** $b;
|
|
2650
|
+
next;
|
|
2651
|
+
}
|
|
2652
|
+
|
|
2653
|
+
# return $a * $b if $n == 0;
|
|
2654
|
+
|
|
2655
|
+
if ($_[-2] == 0) {
|
|
2656
|
+
my ($a, $n, $b) = splice @_, -3;
|
|
2657
|
+
push @_, $a * $b;
|
|
2658
|
+
next;
|
|
2659
|
+
}
|
|
2660
|
+
|
|
2661
|
+
# return 1 if $b == 0;
|
|
2662
|
+
|
|
2663
|
+
if ($_[-1] == 0) {
|
|
2664
|
+
splice @_, -3;
|
|
2665
|
+
push @_, $class -> bone();
|
|
2666
|
+
next;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
# return buparrow($a, $n - 1, buparrow($a, $n, $b - 1));
|
|
2670
|
+
|
|
2671
|
+
my ($a, $n, $b) = splice @_, -3;
|
|
2672
|
+
push @_, ($a, $n - 1,
|
|
2673
|
+
$a, $n, $b - 1);
|
|
2674
|
+
|
|
2675
|
+
}
|
|
2676
|
+
|
|
2677
|
+
pop @_;
|
|
2678
|
+
}
|
|
2679
|
+
|
|
2680
|
+
sub backermann {
|
|
2681
|
+
my $m = shift;
|
|
2682
|
+
my $y = $m -> ackermann(@_);
|
|
2683
|
+
$m -> {value} = $y -> {value};
|
|
2684
|
+
return $m;
|
|
2685
|
+
}
|
|
2686
|
+
|
|
2687
|
+
sub ackermann {
|
|
2688
|
+
# Ackermann's function ackermann(m, n)
|
|
2689
|
+
#
|
|
2690
|
+
# The following is a simple, recursive implementation of the ackermann
|
|
2691
|
+
# function, just to show the idea. Such implementations cause "Deep
|
|
2692
|
+
# recursion on subroutine ..." warnings, so we use a faster, non-recursive
|
|
2693
|
+
# algorithm below with @_ as a stack.
|
|
2694
|
+
#
|
|
2695
|
+
# sub ackermann {
|
|
2696
|
+
# my ($m, $n) = @_;
|
|
2697
|
+
# return $n + 1 if $m == 0;
|
|
2698
|
+
# return ackermann($m - 1, 1) if $m > 0 && $n == 0;
|
|
2699
|
+
# return ackermann($m - 1, ackermann($m, $n - 1) if $m > 0 && $n > 0;
|
|
2700
|
+
# }
|
|
2701
|
+
|
|
2702
|
+
my ($m, $n) = @_;
|
|
2703
|
+
my $class = ref $m;
|
|
2704
|
+
croak("m must be non-negative") if $m < 0;
|
|
2705
|
+
croak("n must be non-negative") if $n < 0;
|
|
2706
|
+
|
|
2707
|
+
my $two = $class -> new("2");
|
|
2708
|
+
my $three = $class -> new("3");
|
|
2709
|
+
my $thirteen = $class -> new("13");
|
|
2710
|
+
|
|
2711
|
+
$n = pop;
|
|
2712
|
+
$n = $class -> new($n) unless ref($n);
|
|
2713
|
+
while (@_) {
|
|
2714
|
+
my $m = pop;
|
|
2715
|
+
if ($m > $three) {
|
|
2716
|
+
push @_, (--$m) x $n;
|
|
2717
|
+
while (--$m >= $three) {
|
|
2718
|
+
push @_, $m;
|
|
2719
|
+
}
|
|
2720
|
+
$n = $thirteen;
|
|
2721
|
+
} elsif ($m == $three) {
|
|
2722
|
+
$n = $class -> bone() -> blsft($n + $three) -> bsub($three);
|
|
2723
|
+
} elsif ($m == $two) {
|
|
2724
|
+
$n -> bmul($two) -> badd($three);
|
|
2725
|
+
} elsif ($m >= 0) {
|
|
2726
|
+
$n -> badd($m) -> binc();
|
|
2727
|
+
} else {
|
|
2728
|
+
die "negative m!";
|
|
2729
|
+
}
|
|
2730
|
+
}
|
|
2731
|
+
$n;
|
|
2732
|
+
}
|
|
2733
|
+
|
|
2605
2734
|
sub bsin {
|
|
2606
2735
|
# Calculate sinus(x) to N digits. Unless upgrading is in effect, returns the
|
|
2607
2736
|
# result truncated to an integer.
|
|
@@ -2654,9 +2783,9 @@ sub batan {
|
|
|
2654
2783
|
return $upgrade->new($x)->batan(@r) if defined $upgrade;
|
|
2655
2784
|
|
|
2656
2785
|
# calculate the result and truncate it to integer
|
|
2657
|
-
my $
|
|
2786
|
+
my $tmp = Math::BigFloat->new($x)->batan(@r);
|
|
2658
2787
|
|
|
2659
|
-
$x->{value} = $LIB->_new($
|
|
2788
|
+
$x->{value} = $LIB->_new($tmp->as_int()->bstr());
|
|
2660
2789
|
$x->round(@r);
|
|
2661
2790
|
}
|
|
2662
2791
|
|
|
@@ -2902,12 +3031,19 @@ sub blsft {
|
|
|
2902
3031
|
# (BINT or num_str, BINT or num_str) return BINT
|
|
2903
3032
|
# compute x << y, base n, y >= 0
|
|
2904
3033
|
|
|
2905
|
-
|
|
2906
|
-
my ($class, $x, $y, $b, @r) = (ref($_[0]), @_);
|
|
3034
|
+
my ($class, $x, $y, $b, @r);
|
|
2907
3035
|
|
|
2908
|
-
#
|
|
2909
|
-
|
|
2910
|
-
|
|
3036
|
+
# Objectify the base only when it is defined, since an undefined base, as
|
|
3037
|
+
# in $x->blsft(3) or $x->blog(3, undef) means use the default base 2.
|
|
3038
|
+
|
|
3039
|
+
if (!ref($_[0]) && $_[0] =~ /^[A-Za-z]|::/) {
|
|
3040
|
+
# E.g., Math::BigInt->blog(256, 5, 2)
|
|
3041
|
+
($class, $x, $y, $b, @r) =
|
|
3042
|
+
defined $_[3] ? objectify(3, @_) : objectify(2, @_);
|
|
3043
|
+
} else {
|
|
3044
|
+
# E.g., Math::BigInt::blog(256, 5, 2) or $x->blog(5, 2)
|
|
3045
|
+
($class, $x, $y, $b, @r) =
|
|
3046
|
+
defined $_[2] ? objectify(3, @_) : objectify(2, @_);
|
|
2911
3047
|
}
|
|
2912
3048
|
|
|
2913
3049
|
return $x if $x -> modify('blsft');
|
|
@@ -2915,7 +3051,15 @@ sub blsft {
|
|
|
2915
3051
|
$y -> {sign} !~ /^[+-]$/);
|
|
2916
3052
|
return $x -> round(@r) if $y -> is_zero();
|
|
2917
3053
|
|
|
2918
|
-
$b =
|
|
3054
|
+
$b = defined($b) ? $b -> numify() : 2;
|
|
3055
|
+
|
|
3056
|
+
# While some of the libraries support an arbitrarily large base, not all of
|
|
3057
|
+
# them do, so rather than returning an incorrect result in those cases,
|
|
3058
|
+
# disallow bases that don't work with all libraries.
|
|
3059
|
+
|
|
3060
|
+
my $uintmax = ~0;
|
|
3061
|
+
croak("Base is too large.") if $b > $uintmax;
|
|
3062
|
+
|
|
2919
3063
|
return $x -> bnan() if $b <= 0 || $y -> {sign} eq '-';
|
|
2920
3064
|
|
|
2921
3065
|
$x -> {value} = $LIB -> _lsft($x -> {value}, $y -> {value}, $b);
|
|
@@ -3146,7 +3290,7 @@ sub bround {
|
|
|
3146
3290
|
# do not return $x->bnorm(), but $x
|
|
3147
3291
|
|
|
3148
3292
|
my $x = shift;
|
|
3149
|
-
$x =
|
|
3293
|
+
$x = __PACKAGE__->new($x) unless ref $x;
|
|
3150
3294
|
my ($scale, $mode) = $x->_scale_a(@_);
|
|
3151
3295
|
return $x if !defined $scale || $x->modify('bround'); # no-op
|
|
3152
3296
|
|
|
@@ -3264,7 +3408,7 @@ sub fround {
|
|
|
3264
3408
|
# Exists to make life easier for switch between MBF and MBI (should we
|
|
3265
3409
|
# autoload fxxx() like MBF does for bxxx()?)
|
|
3266
3410
|
my $x = shift;
|
|
3267
|
-
$x =
|
|
3411
|
+
$x = __PACKAGE__->new($x) unless ref $x;
|
|
3268
3412
|
$x->bround(@_);
|
|
3269
3413
|
}
|
|
3270
3414
|
|
|
@@ -3356,6 +3500,31 @@ sub digit {
|
|
|
3356
3500
|
$LIB->_digit($x->{value}, $n || 0);
|
|
3357
3501
|
}
|
|
3358
3502
|
|
|
3503
|
+
sub bdigitsum {
|
|
3504
|
+
# like digitsum(), but assigns the result to the invocand
|
|
3505
|
+
my $x = shift;
|
|
3506
|
+
|
|
3507
|
+
return $x if $x -> is_nan();
|
|
3508
|
+
return $x -> bnan() if $x -> is_inf();
|
|
3509
|
+
|
|
3510
|
+
$x -> {value} = $LIB -> _digitsum($x -> {value});
|
|
3511
|
+
$x -> {sign} = '+';
|
|
3512
|
+
return $x;
|
|
3513
|
+
}
|
|
3514
|
+
|
|
3515
|
+
sub digitsum {
|
|
3516
|
+
# compute sum of decimal digits and return it
|
|
3517
|
+
my $x = shift;
|
|
3518
|
+
my $class = ref $x;
|
|
3519
|
+
|
|
3520
|
+
return $class -> bnan() if $x -> is_nan();
|
|
3521
|
+
return $class -> bnan() if $x -> is_inf();
|
|
3522
|
+
|
|
3523
|
+
my $y = $class -> bzero();
|
|
3524
|
+
$y -> {value} = $LIB -> _digitsum($x -> {value});
|
|
3525
|
+
return $y;
|
|
3526
|
+
}
|
|
3527
|
+
|
|
3359
3528
|
sub length {
|
|
3360
3529
|
my ($class, $x) = ref($_[0]) ? (undef, $_[0]) : objectify(1, @_);
|
|
3361
3530
|
|
|
@@ -3652,7 +3821,7 @@ sub bdstr {
|
|
|
3652
3821
|
sub to_hex {
|
|
3653
3822
|
# return as hex string, with prefixed 0x
|
|
3654
3823
|
my $x = shift;
|
|
3655
|
-
$x =
|
|
3824
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3656
3825
|
|
|
3657
3826
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3658
3827
|
|
|
@@ -3663,7 +3832,7 @@ sub to_hex {
|
|
|
3663
3832
|
sub to_oct {
|
|
3664
3833
|
# return as octal string, with prefixed 0
|
|
3665
3834
|
my $x = shift;
|
|
3666
|
-
$x =
|
|
3835
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3667
3836
|
|
|
3668
3837
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3669
3838
|
|
|
@@ -3674,7 +3843,7 @@ sub to_oct {
|
|
|
3674
3843
|
sub to_bin {
|
|
3675
3844
|
# return as binary string, with prefixed 0b
|
|
3676
3845
|
my $x = shift;
|
|
3677
|
-
$x =
|
|
3846
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3678
3847
|
|
|
3679
3848
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3680
3849
|
|
|
@@ -3685,7 +3854,7 @@ sub to_bin {
|
|
|
3685
3854
|
sub to_bytes {
|
|
3686
3855
|
# return a byte string
|
|
3687
3856
|
my $x = shift;
|
|
3688
|
-
$x =
|
|
3857
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3689
3858
|
|
|
3690
3859
|
croak("to_bytes() requires a finite, non-negative integer")
|
|
3691
3860
|
if $x -> is_neg() || ! $x -> is_int();
|
|
@@ -3699,13 +3868,13 @@ sub to_bytes {
|
|
|
3699
3868
|
sub to_base {
|
|
3700
3869
|
# return a base anything string
|
|
3701
3870
|
my $x = shift;
|
|
3702
|
-
$x =
|
|
3871
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3703
3872
|
|
|
3704
3873
|
croak("the value to convert must be a finite, non-negative integer")
|
|
3705
3874
|
if $x -> is_neg() || !$x -> is_int();
|
|
3706
3875
|
|
|
3707
3876
|
my $base = shift;
|
|
3708
|
-
$base =
|
|
3877
|
+
$base = __PACKAGE__->new($base) unless ref($base);
|
|
3709
3878
|
|
|
3710
3879
|
croak("the base must be a finite integer >= 2")
|
|
3711
3880
|
if $base < 2 || ! $base -> is_int();
|
|
@@ -3729,7 +3898,7 @@ sub to_base {
|
|
|
3729
3898
|
sub as_hex {
|
|
3730
3899
|
# return as hex string, with prefixed 0x
|
|
3731
3900
|
my $x = shift;
|
|
3732
|
-
$x =
|
|
3901
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3733
3902
|
|
|
3734
3903
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3735
3904
|
|
|
@@ -3740,7 +3909,7 @@ sub as_hex {
|
|
|
3740
3909
|
sub as_oct {
|
|
3741
3910
|
# return as octal string, with prefixed 0
|
|
3742
3911
|
my $x = shift;
|
|
3743
|
-
$x =
|
|
3912
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3744
3913
|
|
|
3745
3914
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3746
3915
|
|
|
@@ -3751,7 +3920,7 @@ sub as_oct {
|
|
|
3751
3920
|
sub as_bin {
|
|
3752
3921
|
# return as binary string, with prefixed 0b
|
|
3753
3922
|
my $x = shift;
|
|
3754
|
-
$x =
|
|
3923
|
+
$x = __PACKAGE__->new($x) if !ref($x);
|
|
3755
3924
|
|
|
3756
3925
|
return $x->bstr() if $x->{sign} !~ /^[+-]$/; # inf, nan etc
|
|
3757
3926
|
|
|
@@ -3768,7 +3937,7 @@ sub as_bin {
|
|
|
3768
3937
|
sub numify {
|
|
3769
3938
|
# Make a Perl scalar number from a Math::BigInt object.
|
|
3770
3939
|
my $x = shift;
|
|
3771
|
-
$x =
|
|
3940
|
+
$x = __PACKAGE__->new($x) unless ref $x;
|
|
3772
3941
|
|
|
3773
3942
|
if ($x -> is_nan()) {
|
|
3774
3943
|
require Math::Complex;
|
|
@@ -3817,7 +3986,7 @@ sub objectify {
|
|
|
3817
3986
|
# Check the context.
|
|
3818
3987
|
|
|
3819
3988
|
unless (wantarray) {
|
|
3820
|
-
croak("
|
|
3989
|
+
croak(__PACKAGE__ . "::objectify() needs list context");
|
|
3821
3990
|
}
|
|
3822
3991
|
|
|
3823
3992
|
# Get the number of arguments to objectify.
|
|
@@ -3935,10 +4104,9 @@ sub objectify {
|
|
|
3935
4104
|
sub import {
|
|
3936
4105
|
my $class = shift;
|
|
3937
4106
|
$IMPORT++; # remember we did import()
|
|
3938
|
-
my @a;
|
|
3939
|
-
my $l = scalar @_;
|
|
4107
|
+
my @a; # unrecognized arguments
|
|
3940
4108
|
my $warn_or_die = 0; # 0 - no warn, 1 - warn, 2 - die
|
|
3941
|
-
for (my $i = 0; $i
|
|
4109
|
+
for (my $i = 0; $i <= $#_ ; $i++) {
|
|
3942
4110
|
if ($_[$i] eq ':constant') {
|
|
3943
4111
|
# this causes overlord er load to step in
|
|
3944
4112
|
overload::constant
|
|
@@ -3951,7 +4119,9 @@ sub import {
|
|
|
3951
4119
|
} elsif ($_[$i] =~ /^(lib|try|only)\z/) {
|
|
3952
4120
|
# this causes a different low lib to take care...
|
|
3953
4121
|
$LIB = $_[$i+1] || '';
|
|
3954
|
-
#
|
|
4122
|
+
# try => 0 (no warn)
|
|
4123
|
+
# lib => 1 (warn on fallback)
|
|
4124
|
+
# only => 2 (die on fallback)
|
|
3955
4125
|
$warn_or_die = 1 if $_[$i] eq 'lib';
|
|
3956
4126
|
$warn_or_die = 2 if $_[$i] eq 'only';
|
|
3957
4127
|
$i++;
|
|
@@ -3968,77 +4138,34 @@ sub import {
|
|
|
3968
4138
|
# try to load core math lib
|
|
3969
4139
|
my @c = split /\s*,\s*/, $LIB;
|
|
3970
4140
|
foreach (@c) {
|
|
3971
|
-
|
|
4141
|
+
tr/a-zA-Z0-9://cd; # limit to sane characters
|
|
3972
4142
|
}
|
|
3973
4143
|
push @c, \'Calc' # if all fail, try these
|
|
3974
4144
|
if $warn_or_die < 2; # but not for "only"
|
|
3975
|
-
$LIB = '';
|
|
4145
|
+
$LIB = ''; # signal error
|
|
3976
4146
|
foreach my $l (@c) {
|
|
3977
4147
|
# fallback libraries are "marked" as \'string', extract string if nec.
|
|
3978
4148
|
my $lib = $l;
|
|
3979
4149
|
$lib = $$l if ref($l);
|
|
3980
4150
|
|
|
3981
|
-
next
|
|
4151
|
+
next unless defined($lib) && CORE::length($lib);
|
|
3982
4152
|
$lib = 'Math::BigInt::'.$lib if $lib !~ /^Math::BigInt/i;
|
|
3983
4153
|
$lib =~ s/\.pm$//;
|
|
3984
|
-
|
|
3985
|
-
#
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
$file .= '.pm'; # BigInt => BigInt.pm
|
|
3990
|
-
require File::Spec;
|
|
3991
|
-
$file = File::Spec->catfile (@parts, $file);
|
|
3992
|
-
eval {
|
|
3993
|
-
require "$file";
|
|
3994
|
-
$lib->import(@c);
|
|
3995
|
-
}
|
|
3996
|
-
} else {
|
|
3997
|
-
eval "use $lib qw/@c/;";
|
|
3998
|
-
}
|
|
4154
|
+
my @parts = split /::/, $lib; # Math::BigInt => Math BigInt
|
|
4155
|
+
$parts[-1] .= '.pm'; # BigInt => BigInt.pm
|
|
4156
|
+
require File::Spec;
|
|
4157
|
+
my $file = File::Spec->catfile(@parts);
|
|
4158
|
+
eval { require $file; };
|
|
3999
4159
|
if ($@ eq '') {
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
if ($
|
|
4003
|
-
$
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
str num
|
|
4008
|
-
add mul div sub dec inc
|
|
4009
|
-
acmp len digit is_one is_zero is_even is_odd
|
|
4010
|
-
is_two is_ten
|
|
4011
|
-
zeros new copy check
|
|
4012
|
-
from_hex from_oct from_bin as_hex as_bin as_oct
|
|
4013
|
-
rsft lsft xor and or
|
|
4014
|
-
mod sqrt root fac pow modinv modpow log_int gcd
|
|
4015
|
-
/) {
|
|
4016
|
-
if (!$lib->can("_$method")) {
|
|
4017
|
-
if (($WARN{$lib} || 0) < 2) {
|
|
4018
|
-
carp("$lib is missing method '_$method'");
|
|
4019
|
-
$WARN{$lib} = 1; # still warn about the lib
|
|
4020
|
-
}
|
|
4021
|
-
$ok++;
|
|
4022
|
-
last;
|
|
4023
|
-
}
|
|
4024
|
-
}
|
|
4025
|
-
}
|
|
4026
|
-
if ($ok == 0) {
|
|
4027
|
-
$LIB = $lib;
|
|
4028
|
-
if ($warn_or_die > 0 && ref($l)) {
|
|
4029
|
-
my $msg = "Math::BigInt: couldn't load specified"
|
|
4030
|
-
. " math lib(s), fallback to $lib";
|
|
4031
|
-
carp($msg) if $warn_or_die == 1;
|
|
4032
|
-
croak($msg) if $warn_or_die == 2;
|
|
4033
|
-
}
|
|
4034
|
-
last; # found a usable one, break
|
|
4035
|
-
} else {
|
|
4036
|
-
if (($WARN{$lib} || 0) < 2) {
|
|
4037
|
-
my $ver = eval "\$$lib\::VERSION" || 'unknown';
|
|
4038
|
-
carp("Cannot load outdated $lib v$ver, please upgrade");
|
|
4039
|
-
$WARN{$lib} = 2; # never warn again
|
|
4040
|
-
}
|
|
4160
|
+
$lib->import();
|
|
4161
|
+
$LIB = $lib;
|
|
4162
|
+
if ($warn_or_die > 0 && ref($l)) {
|
|
4163
|
+
my $msg = "Math::BigInt: couldn't load specified"
|
|
4164
|
+
. " math lib(s), fallback to $lib";
|
|
4165
|
+
carp($msg) if $warn_or_die == 1;
|
|
4166
|
+
croak($msg) if $warn_or_die == 2;
|
|
4041
4167
|
}
|
|
4168
|
+
last; # found a usable one, break
|
|
4042
4169
|
}
|
|
4043
4170
|
}
|
|
4044
4171
|
if ($LIB eq '') {
|
|
@@ -4210,7 +4337,7 @@ sub _split {
|
|
|
4210
4337
|
sub _trailing_zeros {
|
|
4211
4338
|
# return the amount of trailing zeros in $x (as scalar)
|
|
4212
4339
|
my $x = shift;
|
|
4213
|
-
$x =
|
|
4340
|
+
$x = __PACKAGE__->new($x) unless ref $x;
|
|
4214
4341
|
|
|
4215
4342
|
return 0 if $x->{sign} !~ /^[+-]$/; # NaN, inf, -inf etc
|
|
4216
4343
|
|
|
@@ -4423,6 +4550,8 @@ Math::BigInt - Arbitrary size integer/float math package
|
|
|
4423
4550
|
$x->blog($base); # logarithm of $x to base $base (e.g., base 2)
|
|
4424
4551
|
$x->bexp(); # calculate e ** $x where e is Euler's number
|
|
4425
4552
|
$x->bnok($y); # x over y (binomial coefficient n over k)
|
|
4553
|
+
$x->buparrow($n, $y); # Knuth's up-arrow notation
|
|
4554
|
+
$x->backermann($y); # the Ackermann function
|
|
4426
4555
|
$x->bsin(); # sine
|
|
4427
4556
|
$x->bcos(); # cosine
|
|
4428
4557
|
$x->batan(); # inverse tangent
|
|
@@ -4987,6 +5116,18 @@ neither positive nor negative.
|
|
|
4987
5116
|
Returns true if the invocand is negative and false otherwise. A C<NaN> is
|
|
4988
5117
|
neither positive nor negative.
|
|
4989
5118
|
|
|
5119
|
+
=item is_non_positive()
|
|
5120
|
+
|
|
5121
|
+
$x->is_non_positive(); # true if <= 0
|
|
5122
|
+
|
|
5123
|
+
Returns true if the invocand is negative or zero.
|
|
5124
|
+
|
|
5125
|
+
=item is_non_negative()
|
|
5126
|
+
|
|
5127
|
+
$x->is_non_negative(); # true if >= 0
|
|
5128
|
+
|
|
5129
|
+
Returns true if the invocand is positive or zero.
|
|
5130
|
+
|
|
4990
5131
|
=item is_odd()
|
|
4991
5132
|
|
|
4992
5133
|
$x->is_odd(); # true if odd, false for even
|
|
@@ -5292,6 +5433,38 @@ pseudo-code:
|
|
|
5292
5433
|
The behaviour is identical to the behaviour of the Maple and Mathematica
|
|
5293
5434
|
function for negative integers n, k.
|
|
5294
5435
|
|
|
5436
|
+
=item buparrow()
|
|
5437
|
+
|
|
5438
|
+
=item uparrow()
|
|
5439
|
+
|
|
5440
|
+
$a -> buparrow($n, $b); # modifies $a
|
|
5441
|
+
$x = $a -> uparrow($n, $b); # does not modify $a
|
|
5442
|
+
|
|
5443
|
+
This method implements Knuth's up-arrow notation, where $n is a non-negative
|
|
5444
|
+
integer representing the number of up-arrows. $n = 0 gives multiplication, $n =
|
|
5445
|
+
1 gives exponentiation, $n = 2 gives tetration, $n = 3 gives hexation etc. The
|
|
5446
|
+
following illustrates the relation between the first values of $n.
|
|
5447
|
+
|
|
5448
|
+
See L<https://en.wikipedia.org/wiki/Knuth%27s_up-arrow_notation>.
|
|
5449
|
+
|
|
5450
|
+
=item backermann()
|
|
5451
|
+
|
|
5452
|
+
=item ackermann()
|
|
5453
|
+
|
|
5454
|
+
$m -> backermann($n); # modifies $a
|
|
5455
|
+
$x = $m -> ackermann($n); # does not modify $a
|
|
5456
|
+
|
|
5457
|
+
This method implements the Ackermann function:
|
|
5458
|
+
|
|
5459
|
+
/ n + 1 if m = 0
|
|
5460
|
+
A(m, n) = | A(m-1, 1) if m > 0 and n = 0
|
|
5461
|
+
\ A(m-1, A(m, n-1)) if m > 0 and n > 0
|
|
5462
|
+
|
|
5463
|
+
Its value grows rapidly, even for small inputs. For example, A(4, 2) is an
|
|
5464
|
+
integer of 19729 decimal digits.
|
|
5465
|
+
|
|
5466
|
+
See https://en.wikipedia.org/wiki/Ackermann_function
|
|
5467
|
+
|
|
5295
5468
|
=item bsin()
|
|
5296
5469
|
|
|
5297
5470
|
my $x = Math::BigInt->new(1);
|
|
@@ -5590,6 +5763,18 @@ If you want $x to have a certain sign, use one of the following methods:
|
|
|
5590
5763
|
|
|
5591
5764
|
If C<$n> is negative, returns the digit counting from left.
|
|
5592
5765
|
|
|
5766
|
+
=item digitsum()
|
|
5767
|
+
|
|
5768
|
+
$x->digitsum();
|
|
5769
|
+
|
|
5770
|
+
Computes the sum of the base 10 digits and returns it.
|
|
5771
|
+
|
|
5772
|
+
=item bdigitsum()
|
|
5773
|
+
|
|
5774
|
+
$x->bdigitsum();
|
|
5775
|
+
|
|
5776
|
+
Computes the sum of the base 10 digits and assigns the result to the invocand.
|
|
5777
|
+
|
|
5593
5778
|
=item length()
|
|
5594
5779
|
|
|
5595
5780
|
$x->length();
|
|
@@ -6696,11 +6881,11 @@ L<http://annocpan.org/dist/Math-BigInt>
|
|
|
6696
6881
|
|
|
6697
6882
|
=item * CPAN Ratings
|
|
6698
6883
|
|
|
6699
|
-
L<
|
|
6884
|
+
L<https://cpanratings.perl.org/dist/Math-BigInt>
|
|
6700
6885
|
|
|
6701
|
-
=item *
|
|
6886
|
+
=item * MetaCPAN
|
|
6702
6887
|
|
|
6703
|
-
L<
|
|
6888
|
+
L<https://metacpan.org/release/Math-BigInt>
|
|
6704
6889
|
|
|
6705
6890
|
=item * CPAN Testers Matrix
|
|
6706
6891
|
|