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
|
@@ -19,8 +19,9 @@ use warnings;
|
|
|
19
19
|
use Carp qw< carp croak >;
|
|
20
20
|
use Math::BigInt ();
|
|
21
21
|
|
|
22
|
-
our $VERSION = '1.
|
|
22
|
+
our $VERSION = '1.999818';
|
|
23
23
|
|
|
24
|
+
require Exporter;
|
|
24
25
|
our @ISA = qw/Math::BigInt/;
|
|
25
26
|
our @EXPORT_OK = qw/bpi/;
|
|
26
27
|
|
|
@@ -28,8 +29,6 @@ our @EXPORT_OK = qw/bpi/;
|
|
|
28
29
|
our ($AUTOLOAD, $accuracy, $precision, $div_scale, $round_mode, $rnd_mode,
|
|
29
30
|
$upgrade, $downgrade, $_trap_nan, $_trap_inf);
|
|
30
31
|
|
|
31
|
-
my $class = "Math::BigFloat";
|
|
32
|
-
|
|
33
32
|
use overload
|
|
34
33
|
|
|
35
34
|
# overload key: with_assign
|
|
@@ -273,7 +272,7 @@ sub AUTOLOAD {
|
|
|
273
272
|
my $name = $AUTOLOAD;
|
|
274
273
|
|
|
275
274
|
$name =~ s/(.*):://; # split package
|
|
276
|
-
my $c = $1 ||
|
|
275
|
+
my $c = $1 || __PACKAGE__;
|
|
277
276
|
no strict 'refs';
|
|
278
277
|
$c->import() if $IMPORT == 0;
|
|
279
278
|
if (!_method_alias($name)) {
|
|
@@ -418,7 +417,8 @@ sub new {
|
|
|
418
417
|
return $self;
|
|
419
418
|
}
|
|
420
419
|
|
|
421
|
-
# Handle hexadecimal numbers.
|
|
420
|
+
# Handle hexadecimal numbers. We auto-detect hexadecimal numbers if they
|
|
421
|
+
# have a "0x" or "0X" prefix.
|
|
422
422
|
|
|
423
423
|
if ($wanted =~ /^\s*[+-]?0[Xx]/) {
|
|
424
424
|
$self = $class -> from_hex($wanted);
|
|
@@ -426,7 +426,42 @@ sub new {
|
|
|
426
426
|
return $self;
|
|
427
427
|
}
|
|
428
428
|
|
|
429
|
-
# Handle
|
|
429
|
+
# Handle octal numbers. We auto-detect octal numbers if they have a "0"
|
|
430
|
+
# prefix and a binary exponent.
|
|
431
|
+
|
|
432
|
+
if ($wanted =~ /
|
|
433
|
+
^
|
|
434
|
+
\s*
|
|
435
|
+
|
|
436
|
+
# sign
|
|
437
|
+
[+-]?
|
|
438
|
+
|
|
439
|
+
# prefix
|
|
440
|
+
0
|
|
441
|
+
|
|
442
|
+
# significand using the octal digits 0..7
|
|
443
|
+
[0-7]+ (?: _ [0-7]+ )*
|
|
444
|
+
(?:
|
|
445
|
+
\.
|
|
446
|
+
(?: [0-7]+ (?: _ [0-7]+ )* )?
|
|
447
|
+
)?
|
|
448
|
+
|
|
449
|
+
# exponent (power of 2) using decimal digits
|
|
450
|
+
[Pp]
|
|
451
|
+
[+-]?
|
|
452
|
+
\d+ (?: _ \d+ )*
|
|
453
|
+
|
|
454
|
+
\s*
|
|
455
|
+
$
|
|
456
|
+
/x)
|
|
457
|
+
{
|
|
458
|
+
$self = $class -> from_oct($wanted);
|
|
459
|
+
$self->round(@r) unless @r >= 2 && !defined $r[0] && !defined $r[1];
|
|
460
|
+
return $self;
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
# Handle binary numbers. We auto-detect binary numbers if they have a "0b"
|
|
464
|
+
# or "0B" prefix.
|
|
430
465
|
|
|
431
466
|
if ($wanted =~ /^\s*[+-]?0[Bb]/) {
|
|
432
467
|
$self = $class -> from_bin($wanted);
|
|
@@ -781,6 +816,165 @@ sub from_bin {
|
|
|
781
816
|
return $self->bnan();
|
|
782
817
|
}
|
|
783
818
|
|
|
819
|
+
sub from_ieee754 {
|
|
820
|
+
my $self = shift;
|
|
821
|
+
my $selfref = ref $self;
|
|
822
|
+
my $class = $selfref || $self;
|
|
823
|
+
|
|
824
|
+
# Don't modify constant (read-only) objects.
|
|
825
|
+
|
|
826
|
+
return if $selfref && $self->modify('from_ieee754');
|
|
827
|
+
|
|
828
|
+
my $in = shift; # input string (or raw bytes)
|
|
829
|
+
my $format = shift; # format ("binary32", "decimal64" etc.)
|
|
830
|
+
my $enc; # significand encoding (applies only to decimal)
|
|
831
|
+
my $k; # storage width in bits
|
|
832
|
+
my $b; # base
|
|
833
|
+
|
|
834
|
+
if ($format =~ /^binary(\d+)\z/) {
|
|
835
|
+
$k = $1;
|
|
836
|
+
$b = 2;
|
|
837
|
+
} elsif ($format =~ /^decimal(\d+)(dpd|bcd)?\z/) {
|
|
838
|
+
$k = $1;
|
|
839
|
+
$b = 10;
|
|
840
|
+
$enc = $2 || 'dpd'; # default is dencely-packed decimals (DPD)
|
|
841
|
+
} elsif ($format eq 'half') {
|
|
842
|
+
$k = 16;
|
|
843
|
+
$b = 2;
|
|
844
|
+
} elsif ($format eq 'single') {
|
|
845
|
+
$k = 32;
|
|
846
|
+
$b = 2;
|
|
847
|
+
} elsif ($format eq 'double') {
|
|
848
|
+
$k = 64;
|
|
849
|
+
$b = 2;
|
|
850
|
+
} elsif ($format eq 'quadruple') {
|
|
851
|
+
$k = 128;
|
|
852
|
+
$b = 2;
|
|
853
|
+
} elsif ($format eq 'octuple') {
|
|
854
|
+
$k = 256;
|
|
855
|
+
$b = 2;
|
|
856
|
+
} elsif ($format eq 'sexdecuple') {
|
|
857
|
+
$k = 512;
|
|
858
|
+
$b = 2;
|
|
859
|
+
}
|
|
860
|
+
|
|
861
|
+
if ($b == 2) {
|
|
862
|
+
|
|
863
|
+
# Get the parameters for this format.
|
|
864
|
+
|
|
865
|
+
my $p; # precision (in bits)
|
|
866
|
+
my $t; # number of bits in significand
|
|
867
|
+
my $w; # number of bits in exponent
|
|
868
|
+
|
|
869
|
+
if ($k == 16) { # binary16 (half-precision)
|
|
870
|
+
$p = 11;
|
|
871
|
+
$t = 10;
|
|
872
|
+
$w = 5;
|
|
873
|
+
} elsif ($k == 32) { # binary32 (single-precision)
|
|
874
|
+
$p = 24;
|
|
875
|
+
$t = 23;
|
|
876
|
+
$w = 8;
|
|
877
|
+
} elsif ($k == 64) { # binary64 (double-precision)
|
|
878
|
+
$p = 53;
|
|
879
|
+
$t = 52;
|
|
880
|
+
$w = 11;
|
|
881
|
+
} else { # binaryN (quadruple-precision and above)
|
|
882
|
+
if ($k < 128 || $k != 32 * sprintf('%.0f', $k / 32)) {
|
|
883
|
+
croak "Number of bits must be 16, 32, 64, or >= 128 and",
|
|
884
|
+
" a multiple of 32";
|
|
885
|
+
}
|
|
886
|
+
$p = $k - sprintf('%.0f', 4 * log($k) / log(2)) + 13;
|
|
887
|
+
$t = $p - 1;
|
|
888
|
+
$w = $k - $t - 1;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
# The maximum exponent, minimum exponent, and exponent bias.
|
|
892
|
+
|
|
893
|
+
my $emax = Math::BigInt -> new(2) -> bpow($w - 1) -> bdec();
|
|
894
|
+
my $emin = 1 - $emax;
|
|
895
|
+
my $bias = $emax;
|
|
896
|
+
|
|
897
|
+
# Undefined input.
|
|
898
|
+
|
|
899
|
+
unless (defined $in) {
|
|
900
|
+
carp("Input is undefined");
|
|
901
|
+
return $self -> bzero();
|
|
902
|
+
}
|
|
903
|
+
|
|
904
|
+
# Make sure input string is a string of zeros and ones.
|
|
905
|
+
|
|
906
|
+
my $len = CORE::length $in;
|
|
907
|
+
if (8 * $len == $k) { # bytes
|
|
908
|
+
$in = unpack "B*", $in;
|
|
909
|
+
} elsif (4 * $len == $k) { # hexadecimal
|
|
910
|
+
if ($in =~ /([^\da-f])/i) {
|
|
911
|
+
croak "Illegal hexadecimal digit '$1'";
|
|
912
|
+
}
|
|
913
|
+
$in = unpack "B*", pack "H*", $in;
|
|
914
|
+
} elsif ($len == $k) { # bits
|
|
915
|
+
if ($in =~ /([^01])/) {
|
|
916
|
+
croak "Illegal binary digit '$1'";
|
|
917
|
+
}
|
|
918
|
+
} else {
|
|
919
|
+
croak "Unknown input -- $in";
|
|
920
|
+
}
|
|
921
|
+
|
|
922
|
+
# Split bit string into sign, exponent, and mantissa/significand.
|
|
923
|
+
|
|
924
|
+
my $sign = substr($in, 0, 1) eq '1' ? '-' : '+';
|
|
925
|
+
my $expo = $class -> from_bin(substr($in, 1, $w));
|
|
926
|
+
my $mant = $class -> from_bin(substr($in, $w + 1));
|
|
927
|
+
|
|
928
|
+
my $x;
|
|
929
|
+
|
|
930
|
+
$expo -> bsub($bias); # subtract bias
|
|
931
|
+
|
|
932
|
+
if ($expo < $emin) { # zero and subnormals
|
|
933
|
+
if ($mant == 0) { # zero
|
|
934
|
+
$x = $class -> bzero();
|
|
935
|
+
} else { # subnormals
|
|
936
|
+
# compute (1/$b)**(N) rather than ($b)**(-N)
|
|
937
|
+
$x = $class -> new("0.5"); # 1/$b
|
|
938
|
+
$x -> bpow($bias + $t - 1) -> bmul($mant);
|
|
939
|
+
$x -> bneg() if $sign eq '-';
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
elsif ($expo > $emax) { # inf and nan
|
|
944
|
+
if ($mant == 0) { # inf
|
|
945
|
+
$x = $class -> binf($sign);
|
|
946
|
+
} else { # nan
|
|
947
|
+
$x = $class -> bnan();
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
else { # normals
|
|
952
|
+
$mant = $class -> new(2) -> bpow($t) -> badd($mant);
|
|
953
|
+
if ($expo < $t) {
|
|
954
|
+
# compute (1/$b)**(N) rather than ($b)**(-N)
|
|
955
|
+
$x = $class -> new("0.5"); # 1/$b
|
|
956
|
+
$x -> bpow($t - $expo) -> bmul($mant);
|
|
957
|
+
} else {
|
|
958
|
+
$x = $class -> new(2);
|
|
959
|
+
$x -> bpow($expo - $t) -> bmul($mant);
|
|
960
|
+
}
|
|
961
|
+
$x -> bneg() if $sign eq '-';
|
|
962
|
+
}
|
|
963
|
+
|
|
964
|
+
if ($selfref) {
|
|
965
|
+
$self -> {sign} = $x -> {sign};
|
|
966
|
+
$self -> {_m} = $x -> {_m};
|
|
967
|
+
$self -> {_es} = $x -> {_es};
|
|
968
|
+
$self -> {_e} = $x -> {_e};
|
|
969
|
+
} else {
|
|
970
|
+
$self = $x;
|
|
971
|
+
}
|
|
972
|
+
return $self;
|
|
973
|
+
}
|
|
974
|
+
|
|
975
|
+
croak("The format '$format' is not yet supported.");
|
|
976
|
+
}
|
|
977
|
+
|
|
784
978
|
sub bzero {
|
|
785
979
|
# create/assign '+0'
|
|
786
980
|
|
|
@@ -3023,7 +3217,7 @@ sub bsqrt {
|
|
|
3023
3217
|
|
|
3024
3218
|
return $x if $x->modify('bsqrt');
|
|
3025
3219
|
|
|
3026
|
-
return $x->bnan() if $x->{sign} !~
|
|
3220
|
+
return $x->bnan() if $x->{sign} !~ /^\+/; # NaN, -inf or < 0
|
|
3027
3221
|
return $x if $x->{sign} eq '+inf'; # sqrt(inf) == inf
|
|
3028
3222
|
return $x->round($a, $p, $r) if $x->is_zero() || $x->is_one();
|
|
3029
3223
|
|
|
@@ -3783,7 +3977,7 @@ sub mantissa {
|
|
|
3783
3977
|
|
|
3784
3978
|
if ($x->{sign} !~ /^[+-]$/) {
|
|
3785
3979
|
my $s = $x->{sign};
|
|
3786
|
-
$s =~ s
|
|
3980
|
+
$s =~ s/^\+//;
|
|
3787
3981
|
return Math::BigInt->new($s, undef, undef); # -inf, +inf => +inf
|
|
3788
3982
|
}
|
|
3789
3983
|
my $m = Math::BigInt->new($LIB->_str($x->{_m}), undef, undef);
|
|
@@ -3798,7 +3992,7 @@ sub exponent {
|
|
|
3798
3992
|
|
|
3799
3993
|
if ($x->{sign} !~ /^[+-]$/) {
|
|
3800
3994
|
my $s = $x->{sign};
|
|
3801
|
-
$s =~ s/^[+-]//;
|
|
3995
|
+
$s =~ s/^[+-]//;
|
|
3802
3996
|
return Math::BigInt->new($s, undef, undef); # -inf, +inf => +inf
|
|
3803
3997
|
}
|
|
3804
3998
|
Math::BigInt->new($x->{_es} . $LIB->_str($x->{_e}), undef, undef);
|
|
@@ -3810,9 +4004,9 @@ sub parts {
|
|
|
3810
4004
|
|
|
3811
4005
|
if ($x->{sign} !~ /^[+-]$/) {
|
|
3812
4006
|
my $s = $x->{sign};
|
|
3813
|
-
$s =~ s
|
|
3814
|
-
my $se = $s;
|
|
3815
|
-
$se =~ s
|
|
4007
|
+
$s =~ s/^\+//;
|
|
4008
|
+
my $se = $s;
|
|
4009
|
+
$se =~ s/^-//;
|
|
3816
4010
|
return ($class->new($s), $class->new($se)); # +inf => inf and -inf, +inf => inf
|
|
3817
4011
|
}
|
|
3818
4012
|
my $m = Math::BigInt->bzero();
|
|
@@ -3981,9 +4175,9 @@ sub bstr {
|
|
|
3981
4175
|
}
|
|
3982
4176
|
|
|
3983
4177
|
my $es = '0';
|
|
3984
|
-
my $len = 1;
|
|
3985
|
-
my $cad = 0;
|
|
3986
|
-
my $dot = '.';
|
|
4178
|
+
my $len = 1;
|
|
4179
|
+
my $cad = 0;
|
|
4180
|
+
my $dot = '.';
|
|
3987
4181
|
|
|
3988
4182
|
# $x is zero?
|
|
3989
4183
|
my $not_zero = !($x->{sign} eq '+' && $LIB->_is_zero($x->{_m}));
|
|
@@ -4007,8 +4201,8 @@ my $dot = '.';
|
|
|
4007
4201
|
} elsif ($e > 0) {
|
|
4008
4202
|
# expand with zeros
|
|
4009
4203
|
$es .= '0' x $e;
|
|
4010
|
-
$len += $e;
|
|
4011
|
-
$cad = 0;
|
|
4204
|
+
$len += $e;
|
|
4205
|
+
$cad = 0;
|
|
4012
4206
|
}
|
|
4013
4207
|
} # if not zero
|
|
4014
4208
|
|
|
@@ -4160,6 +4354,197 @@ sub to_bin {
|
|
|
4160
4354
|
return $x->{sign} eq '-' ? "-$str" : $str;
|
|
4161
4355
|
}
|
|
4162
4356
|
|
|
4357
|
+
sub to_ieee754 {
|
|
4358
|
+
my $x = shift;
|
|
4359
|
+
my $format = shift;
|
|
4360
|
+
my $class = ref $x;
|
|
4361
|
+
|
|
4362
|
+
my $enc; # significand encoding (applies only to decimal)
|
|
4363
|
+
my $k; # storage width in bits
|
|
4364
|
+
my $b; # base
|
|
4365
|
+
|
|
4366
|
+
if ($format =~ /^binary(\d+)\z/) {
|
|
4367
|
+
$k = $1;
|
|
4368
|
+
$b = 2;
|
|
4369
|
+
} elsif ($format =~ /^decimal(\d+)(dpd|bcd)?\z/) {
|
|
4370
|
+
$k = $1;
|
|
4371
|
+
$b = 10;
|
|
4372
|
+
$enc = $2 || 'dpd'; # default is dencely-packed decimals (DPD)
|
|
4373
|
+
} elsif ($format eq 'half') {
|
|
4374
|
+
$k = 16;
|
|
4375
|
+
$b = 2;
|
|
4376
|
+
} elsif ($format eq 'single') {
|
|
4377
|
+
$k = 32;
|
|
4378
|
+
$b = 2;
|
|
4379
|
+
} elsif ($format eq 'double') {
|
|
4380
|
+
$k = 64;
|
|
4381
|
+
$b = 2;
|
|
4382
|
+
} elsif ($format eq 'quadruple') {
|
|
4383
|
+
$k = 128;
|
|
4384
|
+
$b = 2;
|
|
4385
|
+
} elsif ($format eq 'octuple') {
|
|
4386
|
+
$k = 256;
|
|
4387
|
+
$b = 2;
|
|
4388
|
+
} elsif ($format eq 'sexdecuple') {
|
|
4389
|
+
$k = 512;
|
|
4390
|
+
$b = 2;
|
|
4391
|
+
}
|
|
4392
|
+
|
|
4393
|
+
if ($b == 2) {
|
|
4394
|
+
|
|
4395
|
+
# Get the parameters for this format.
|
|
4396
|
+
|
|
4397
|
+
my $p; # precision (in bits)
|
|
4398
|
+
my $t; # number of bits in significand
|
|
4399
|
+
my $w; # number of bits in exponent
|
|
4400
|
+
|
|
4401
|
+
if ($k == 16) { # binary16 (half-precision)
|
|
4402
|
+
$p = 11;
|
|
4403
|
+
$t = 10;
|
|
4404
|
+
$w = 5;
|
|
4405
|
+
} elsif ($k == 32) { # binary32 (single-precision)
|
|
4406
|
+
$p = 24;
|
|
4407
|
+
$t = 23;
|
|
4408
|
+
$w = 8;
|
|
4409
|
+
} elsif ($k == 64) { # binary64 (double-precision)
|
|
4410
|
+
$p = 53;
|
|
4411
|
+
$t = 52;
|
|
4412
|
+
$w = 11;
|
|
4413
|
+
} else { # binaryN (quadruple-precition and above)
|
|
4414
|
+
if ($k < 128 || $k != 32 * sprintf('%.0f', $k / 32)) {
|
|
4415
|
+
croak "Number of bits must be 16, 32, 64, or >= 128 and",
|
|
4416
|
+
" a multiple of 32";
|
|
4417
|
+
}
|
|
4418
|
+
$p = $k - sprintf('%.0f', 4 * log($k) / log(2)) + 13;
|
|
4419
|
+
$t = $p - 1;
|
|
4420
|
+
$w = $k - $t - 1;
|
|
4421
|
+
}
|
|
4422
|
+
|
|
4423
|
+
# The maximum exponent, minimum exponent, and exponent bias.
|
|
4424
|
+
|
|
4425
|
+
my $emax = $class -> new(2) -> bpow($w - 1) -> bdec();
|
|
4426
|
+
my $emin = 1 - $emax;
|
|
4427
|
+
my $bias = $emax;
|
|
4428
|
+
|
|
4429
|
+
# Get numerical sign, exponent, and mantissa/significand for bit
|
|
4430
|
+
# string.
|
|
4431
|
+
|
|
4432
|
+
my $sign = 0;
|
|
4433
|
+
my $expo;
|
|
4434
|
+
my $mant;
|
|
4435
|
+
|
|
4436
|
+
if ($x -> is_nan()) { # nan
|
|
4437
|
+
$sign = 1;
|
|
4438
|
+
$expo = $emax -> copy() -> binc();
|
|
4439
|
+
$mant = $class -> new(2) -> bpow($t - 1);
|
|
4440
|
+
} elsif ($x -> is_inf()) { # inf
|
|
4441
|
+
$sign = 1 if $x -> is_neg();
|
|
4442
|
+
$expo = $emax -> copy() -> binc();
|
|
4443
|
+
$mant = $class -> bzero();
|
|
4444
|
+
} elsif ($x -> is_zero()) { # zero
|
|
4445
|
+
$expo = $emin -> copy() -> bdec();
|
|
4446
|
+
$mant = $class -> bzero();
|
|
4447
|
+
} else { # normal and subnormal
|
|
4448
|
+
|
|
4449
|
+
$sign = 1 if $x -> is_neg();
|
|
4450
|
+
|
|
4451
|
+
# Now we need to compute the mantissa and exponent in base $b.
|
|
4452
|
+
|
|
4453
|
+
my $binv = $class -> new("0.5");
|
|
4454
|
+
my $b = $class -> new(2);
|
|
4455
|
+
my $one = $class -> bone();
|
|
4456
|
+
|
|
4457
|
+
# We start off by initializing the exponent to zero and the
|
|
4458
|
+
# mantissa to the input value. Then we increase the mantissa and
|
|
4459
|
+
# decrease the exponent, or vice versa, until the mantissa is in
|
|
4460
|
+
# the desired range or we hit one of the limits for the exponent.
|
|
4461
|
+
|
|
4462
|
+
$mant = $x -> copy() -> babs();
|
|
4463
|
+
|
|
4464
|
+
# We need to find the base 2 exponent. First make an estimate of
|
|
4465
|
+
# the base 2 exponent, before adjusting it below. We could skip
|
|
4466
|
+
# this estimation and go straight to the while-loops below, but the
|
|
4467
|
+
# loops are slow, especially when the final exponent is far from
|
|
4468
|
+
# zero and even more so if the number of digits is large. This
|
|
4469
|
+
# initial estimation speeds up the computation dramatically.
|
|
4470
|
+
#
|
|
4471
|
+
# log2($m * 10**$e) = log10($m + 10**$e) * log(10)/log(2)
|
|
4472
|
+
# = (log10($m) + $e) * log(10)/log(2)
|
|
4473
|
+
# = (log($m)/log(10) + $e) * log(10)/log(2)
|
|
4474
|
+
|
|
4475
|
+
my ($m, $e) = $x -> nparts();
|
|
4476
|
+
my $ms = $m -> numify();
|
|
4477
|
+
my $es = $e -> numify();
|
|
4478
|
+
|
|
4479
|
+
my $expo_est = (log(abs($ms))/log(10) + $es) * log(10)/log(2);
|
|
4480
|
+
$expo_est = int($expo_est);
|
|
4481
|
+
|
|
4482
|
+
# Limit the exponent.
|
|
4483
|
+
|
|
4484
|
+
if ($expo_est > $emax) {
|
|
4485
|
+
$expo_est = $emax;
|
|
4486
|
+
} elsif ($expo_est < $emin) {
|
|
4487
|
+
$expo_est = $emin;
|
|
4488
|
+
}
|
|
4489
|
+
|
|
4490
|
+
# Don't multiply by a number raised to a negative exponent. This
|
|
4491
|
+
# will cause a division, whose result is truncated to some fixed
|
|
4492
|
+
# number of digits. Instead, multiply by the inverse number raised
|
|
4493
|
+
# to a positive exponent.
|
|
4494
|
+
|
|
4495
|
+
$expo = $class -> new($expo_est);
|
|
4496
|
+
if ($expo_est > 0) {
|
|
4497
|
+
$mant -> bmul($binv -> copy() -> bpow($expo));
|
|
4498
|
+
} elsif ($expo_est < 0) {
|
|
4499
|
+
my $expo_abs = $expo -> copy() -> bneg();
|
|
4500
|
+
$mant -> bmul($b -> copy() -> bpow($expo_abs));
|
|
4501
|
+
}
|
|
4502
|
+
|
|
4503
|
+
# Final adjustment.
|
|
4504
|
+
|
|
4505
|
+
while ($mant >= $b && $expo <= $emax) {
|
|
4506
|
+
$mant -> bmul($binv);
|
|
4507
|
+
$expo -> binc();
|
|
4508
|
+
}
|
|
4509
|
+
|
|
4510
|
+
while ($mant < $one && $expo >= $emin) {
|
|
4511
|
+
$mant -> bmul($b);
|
|
4512
|
+
$expo -> bdec();
|
|
4513
|
+
}
|
|
4514
|
+
|
|
4515
|
+
# Encode as infinity, normal number or subnormal number?
|
|
4516
|
+
|
|
4517
|
+
if ($expo > $emax) { # overflow => infinity
|
|
4518
|
+
$expo = $emax -> copy() -> binc();
|
|
4519
|
+
$mant = $class -> bzero();
|
|
4520
|
+
} elsif ($expo < $emin) { # subnormal number
|
|
4521
|
+
my $const = $class -> new(2) -> bpow($t - 1);
|
|
4522
|
+
$mant -> bmul($const);
|
|
4523
|
+
$mant -> bfround(0);
|
|
4524
|
+
} else { # normal number
|
|
4525
|
+
$mant -> bdec(); # remove implicit leading bit
|
|
4526
|
+
my $const = $class -> new(2) -> bpow($t);
|
|
4527
|
+
$mant -> bmul($const) -> bfround(0);
|
|
4528
|
+
}
|
|
4529
|
+
}
|
|
4530
|
+
|
|
4531
|
+
$expo -> badd($bias); # add bias
|
|
4532
|
+
|
|
4533
|
+
my $signbit = "$sign";
|
|
4534
|
+
|
|
4535
|
+
my $mantbits = $mant -> to_bin();
|
|
4536
|
+
$mantbits = ("0" x ($t - CORE::length($mantbits))) . $mantbits;
|
|
4537
|
+
|
|
4538
|
+
my $expobits = $expo -> to_bin();
|
|
4539
|
+
$expobits = ("0" x ($w - CORE::length($expobits))) . $expobits;
|
|
4540
|
+
|
|
4541
|
+
my $bin = $signbit . $expobits . $mantbits;
|
|
4542
|
+
return pack "B*", $bin;
|
|
4543
|
+
}
|
|
4544
|
+
|
|
4545
|
+
croak("The format '$format' is not yet supported.");
|
|
4546
|
+
}
|
|
4547
|
+
|
|
4163
4548
|
sub as_hex {
|
|
4164
4549
|
# return number as hexadecimal string (only for integers defined)
|
|
4165
4550
|
|
|
@@ -4231,7 +4616,7 @@ sub numify {
|
|
|
4231
4616
|
}
|
|
4232
4617
|
|
|
4233
4618
|
# Create a string and let Perl's atoi()/atof() handle the rest.
|
|
4234
|
-
return 0 + $x ->
|
|
4619
|
+
return 0 + $x -> bnstr();
|
|
4235
4620
|
}
|
|
4236
4621
|
|
|
4237
4622
|
###############################################################################
|
|
@@ -4242,7 +4627,7 @@ sub import {
|
|
|
4242
4627
|
my $class = shift;
|
|
4243
4628
|
my $l = scalar @_;
|
|
4244
4629
|
my $lib = '';
|
|
4245
|
-
my @a;
|
|
4630
|
+
my @a;
|
|
4246
4631
|
my $lib_kind = 'try';
|
|
4247
4632
|
$IMPORT=1;
|
|
4248
4633
|
for (my $i = 0; $i < $l ; $i++) {
|
|
@@ -4314,7 +4699,7 @@ sub _len_to_steps {
|
|
|
4314
4699
|
|
|
4315
4700
|
# D = 50 => N => 42, so L = 40 and R = 50
|
|
4316
4701
|
my $l = 40;
|
|
4317
|
-
my $r = $d;
|
|
4702
|
+
my $r = $d;
|
|
4318
4703
|
|
|
4319
4704
|
# Otherwise this does not work under -Mbignum and we do not yet have "no bignum;" :(
|
|
4320
4705
|
$l = $l->numify if ref($l);
|
|
@@ -4370,7 +4755,6 @@ sub _log {
|
|
|
4370
4755
|
$over->bmul($u);
|
|
4371
4756
|
$factor = $class->new(3); $f = $class->new(2);
|
|
4372
4757
|
|
|
4373
|
-
my $steps = 0;
|
|
4374
4758
|
$limit = $class->new("1E-". ($scale-1));
|
|
4375
4759
|
|
|
4376
4760
|
while (3 < 5) {
|
|
@@ -4717,7 +5101,6 @@ sub _pow {
|
|
|
4717
5101
|
$over = $u->copy();
|
|
4718
5102
|
|
|
4719
5103
|
$limit = $class->new("1E-". ($scale-1));
|
|
4720
|
-
#my $steps = 0;
|
|
4721
5104
|
while (3 < 5) {
|
|
4722
5105
|
# we calculate the next term, and add it to the last
|
|
4723
5106
|
# when the next term is below our limit, it won't affect the outcome
|
|
@@ -4731,8 +5114,6 @@ sub _pow {
|
|
|
4731
5114
|
$factor->binc();
|
|
4732
5115
|
|
|
4733
5116
|
last if $x->{sign} !~ /^[-+]$/;
|
|
4734
|
-
|
|
4735
|
-
#$steps++;
|
|
4736
5117
|
}
|
|
4737
5118
|
|
|
4738
5119
|
if ($do_invert) {
|
|
@@ -4795,6 +5176,7 @@ Math::BigFloat - Arbitrary size floating point math package
|
|
|
4795
5176
|
$x = Math::BigFloat->from_oct('0377'); # ditto
|
|
4796
5177
|
$x = Math::BigFloat->from_bin('0b1.1001p-4'); # from binary
|
|
4797
5178
|
$x = Math::BigFloat->from_bin('0101'); # ditto
|
|
5179
|
+
$x = Math::BigFloat->from_ieee754($b, "binary64"); # from IEEE-754 bytes
|
|
4798
5180
|
$x = Math::BigFloat->bzero(); # create a +0
|
|
4799
5181
|
$x = Math::BigFloat->bone(); # create a +1
|
|
4800
5182
|
$x = Math::BigFloat->bone('-'); # create a -1
|
|
@@ -4926,6 +5308,7 @@ Math::BigFloat - Arbitrary size floating point math package
|
|
|
4926
5308
|
$x->as_hex(); # as signed hexadecimal string with prefixed 0x
|
|
4927
5309
|
$x->as_bin(); # as signed binary string with prefixed 0b
|
|
4928
5310
|
$x->as_oct(); # as signed octal string with prefixed 0
|
|
5311
|
+
$x->to_ieee754($format); # to bytes encoded according to IEEE 754-2008
|
|
4929
5312
|
|
|
4930
5313
|
# Other conversion methods
|
|
4931
5314
|
|
|
@@ -5106,6 +5489,17 @@ using decimal digits.
|
|
|
5106
5489
|
|
|
5107
5490
|
If called as an instance method, the value is assigned to the invocand.
|
|
5108
5491
|
|
|
5492
|
+
=item from_ieee754()
|
|
5493
|
+
|
|
5494
|
+
Interpret the input as a value encoded as described in IEEE754-2008. The input
|
|
5495
|
+
can be given as a byte string, hex string or binary string. The input is
|
|
5496
|
+
assumed to be in big-endian byte-order.
|
|
5497
|
+
|
|
5498
|
+
# both $dbl and $mbf are 3.141592...
|
|
5499
|
+
$bytes = "\x40\x09\x21\xfb\x54\x44\x2d\x18";
|
|
5500
|
+
$dbl = unpack "d>", $bytes;
|
|
5501
|
+
$mbf = Math::BigFloat -> from_ieee754($bytes, "binary64");
|
|
5502
|
+
|
|
5109
5503
|
=item bpi()
|
|
5110
5504
|
|
|
5111
5505
|
print Math::BigFloat->bpi(100), "\n";
|
|
@@ -5225,6 +5619,29 @@ C<ref($x)-E<gt>new()> can parse to create an object.
|
|
|
5225
5619
|
|
|
5226
5620
|
In Math::BigFloat, C<as_float()> has the same effect as C<copy()>.
|
|
5227
5621
|
|
|
5622
|
+
=item to_ieee754()
|
|
5623
|
+
|
|
5624
|
+
Encodes the invocand as a byte string in the given format as specified in IEEE
|
|
5625
|
+
754-2008. Note that the encoded value is the nearest possible representation of
|
|
5626
|
+
the value. This value might not be exactly the same as the value in the
|
|
5627
|
+
invocand.
|
|
5628
|
+
|
|
5629
|
+
# $x = 3.1415926535897932385
|
|
5630
|
+
$x = Math::BigFloat -> bpi(30);
|
|
5631
|
+
|
|
5632
|
+
$b = $x -> to_ieee754("binary64"); # encode as 8 bytes
|
|
5633
|
+
$h = unpack "H*", $b; # "400921fb54442d18"
|
|
5634
|
+
|
|
5635
|
+
# 3.141592653589793115997963...
|
|
5636
|
+
$y = Math::BigFloat -> from_ieee754($h, "binary64");
|
|
5637
|
+
|
|
5638
|
+
All binary formats in IEEE 754-2008 are accepted. For convenience, som aliases
|
|
5639
|
+
are recognized: "half" for "binary16", "single" for "binary32", "double" for
|
|
5640
|
+
"binary64", "quadruple" for "binary128", "octuple" for "binary256", and
|
|
5641
|
+
"sexdecuple" for "binary512".
|
|
5642
|
+
|
|
5643
|
+
See also L<https://en.wikipedia.org/wiki/IEEE_754>.
|
|
5644
|
+
|
|
5228
5645
|
=back
|
|
5229
5646
|
|
|
5230
5647
|
=head2 ACCURACY AND PRECISION
|
|
@@ -5552,11 +5969,11 @@ L<http://annocpan.org/dist/Math-BigInt>
|
|
|
5552
5969
|
|
|
5553
5970
|
=item * CPAN Ratings
|
|
5554
5971
|
|
|
5555
|
-
L<
|
|
5972
|
+
L<https://cpanratings.perl.org/dist/Math-BigInt>
|
|
5556
5973
|
|
|
5557
|
-
=item *
|
|
5974
|
+
=item * MetaCPAN
|
|
5558
5975
|
|
|
5559
|
-
L<
|
|
5976
|
+
L<https://metacpan.org/release/Math-BigInt>
|
|
5560
5977
|
|
|
5561
5978
|
=item * CPAN Testers Matrix
|
|
5562
5979
|
|