Data-Integer-0.007/0000755000175000017500000000000014776704114011627 5ustar rrrrData-Integer-0.007/META.json0000664000175000017500000000272114776704114013254 0ustar rrrr{ "abstract" : "details of the native integer data type", "author" : [ "Robert Rothenberg " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.74, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Data-Integer", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "0" } }, "runtime" : { "requires" : { "Carp" : "0", "Exporter" : "0", "constant" : "0", "integer" : "0", "parent" : "0", "perl" : "5.006", "strict" : "0", "warnings" : "0" } }, "test" : { "requires" : { "Test::More" : "0" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Integer" }, "repository" : { "type" : "git", "url" : "git://github.com/robrwo/Data-Integer.git" } }, "version" : "0.007", "x_serialization_backend" : "JSON::PP version 4.06" } Data-Integer-0.007/SIGNATURE0000664000175000017500000000532214776704114013117 0ustar rrrrThis file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.89. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: RIPEMD160 SHA256 112158cab06c2c48ac3788caf38dfc81c5d57b084ac3676ba9b031861b256498 Changes SHA256 27d754fcc8449260f4087a4244f3b2aa9400269c5737742f93a47970d81fb957 MANIFEST SHA256 dcd82a3eeab72a8ffd9b6f60d46d2c43d0c7da7995586d8f0577d2d977444913 MANIFEST.SKIP SHA256 ce7aedf557526465ae513aebec2f2ba37b6bed4dfc5ada6cdb2b08b53b41e489 META.json SHA256 d658e7be8d6876253c192291fcff39b47b12d35591831b25dd239ad25e9730fa META.yml SHA256 2bf7a1afd4d46700a666a832fd790f6e0911020215ac152bf774d63adc353653 Makefile.PL SHA256 319a28052787a17def04c7703604d4230fcae84753213a0a76e3039cb495a0cc README SHA256 1a0b295f1e25342165ef2322e1c5d877953077b095f61c7e0550fd947f36d060 SECURITY.md SHA256 8b1e80bfbbd2be3bb69b00cbe240fdf8db654cbb84aa538503c59ae298097b61 lib/Data/Integer.pm SHA256 db7af510ab9c6b0764c41f82a6dcc7d88958a387c98a26f9738406929598b0b8 t/arith.t SHA256 0b405a09fbc812602573d38cc927884934d3663ec8ea74152270d442d4b5776b t/bitwise.t SHA256 ec12983a13a560934ff8b476743713d0afdbb475699314cedc8081866241f5bc t/canon.t SHA256 204d74cdd5c589d80480514acc12a295b8938b4caa49e5f56c886e37ecd90b19 t/const.t SHA256 c3901f9f86974d3a4d70bcfaaa9bb5e6d73552bc8796fc35b2a839c8c3735a3d t/fmt.t SHA256 bc5c58063b6ac5b1e10d55993f687b337b891a23377bef6484e8bb9b7cd0e96b t/hex.t SHA256 504d06d27d04a1df6bc8476d32fe57f3aa7d5e11168f9fa02c5915f18b5e0488 t/marith.t SHA256 3679257bdfb4a07658e98a41325f82c1744f7dae6d1d0151f1b216af0c1df5c9 t/pod_cvg.t SHA256 e16860066c4ca9b2ee9e7d4604297def8a58b53bf0ca03eed863b5d9c5a2ac91 t/pod_syn.t SHA256 f60711ad8dc315f3bad1cfd453c0fc08e178ecf5e60238e9e4237a560a42ac1a t/shift.t -----BEGIN PGP SIGNATURE----- iQGzBAEBAwAdFiEEeIwq7Pfyfxtssr5nHmWrcYGDC6wFAmf7iEwACgkQHmWrcYGD C6zOcwv7BC7um6wtqEI1BK60s6RMsg3NyfpNWw7VRhBjSN8Urc/ZBef+Y4Mb2++P ptPms8h8W+KdJb/Nicmtq/Xy2cBTabL59PNyfYOuYI8pzP70/oz9mdeG/2M3S8KK LWqebKt3ck/a45WH9h4ouPN0vu2RrzJW0mwaHYxCYT7cI6i4NPxJ0amCVVJB5Krb wDT/HMHTZg3P5aGpGuW4Idnccpz9vbaDt4w5UqogcmdBAKG9jVs+GRhYC9Vd5EXH 3YjybzXcfKz1oeOFWJXGJbXgwPw40DFsWKfaYxdiNDWvO5llIAfkgEiJ9RXjG9v1 PBQLZmQfsrN2dc4/2BzSjdXUgFwrKrkjYc7rfvJmt/TH6aagCgerI4xb7Id+tVJb OKKSb0bxOJ6KIu+bRoIsKggLKk9GGQxv4MWFvdwPm3fkZgrZWPXBTL6ufvPz2IPb N3wCaoXUcQwh1+vPbUxxm8LQ00A/ztVu6ImBAjuCKlAu/5OKaHMmv5j8x5geM7bo fE3ikRU6 =iCF3 -----END PGP SIGNATURE----- Data-Integer-0.007/MANIFEST0000644000175000017500000000036414776703703012766 0ustar rrrrChanges lib/Data/Integer.pm Makefile.PL MANIFEST MANIFEST.SKIP META.json META.yml README SECURITY.md SIGNATURE Added here by Module::Build t/arith.t t/bitwise.t t/canon.t t/const.t t/fmt.t t/hex.t t/marith.t t/pod_cvg.t t/pod_syn.t t/shift.t Data-Integer-0.007/t/0000755000175000017500000000000014776704114012072 5ustar rrrrData-Integer-0.007/t/arith.t0000644000175000017500000002756613142153345013374 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 3*14*14 + 3*11*11 + 3*9*9 + 108 + 1749; BEGIN { use_ok "Data::Integer", qw( nint_sgn sint_sgn uint_sgn nint_abs sint_abs uint_abs nint_cmp sint_cmp uint_cmp nint_min sint_min uint_min nint_max sint_max uint_max nint_neg sint_neg uint_neg nint_add sint_add uint_add nint_sub sint_sub uint_sub min_sint max_sint max_uint nint_is_sint nint_is_uint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } my @values = ( min_sint, do { use integer; min_sint|1 }, do { use integer; min_sint>>1 }, -0x123, -1, 0, 1, 0x123, min_sint>>1, max_sint&~1, max_sint, min_sint|0, max_uint&~1, max_uint, ); for(my $ia = @values; $ia--; ) { for(my $ib = @values; $ib--; ) { my($a, $b) = @values[$ia, $ib]; is nint_cmp($a, $b), $ia <=> $ib; nint_is nint_min($a, $b), ($ia < $ib ? $a : $b); nint_is nint_max($a, $b), ($ia < $ib ? $b : $a); if(nint_is_sint($a) && nint_is_sint($b)) { is sint_cmp($a, $b), $ia <=> $ib; nint_is sint_min($a, $b), ($ia < $ib ? $a : $b); nint_is sint_max($a, $b), ($ia < $ib ? $b : $a); } if(nint_is_uint($a) && nint_is_uint($b)) { is uint_cmp($a, $b), $ia <=> $ib; nint_is uint_min($a, $b), ($ia < $ib ? $a : $b); nint_is uint_max($a, $b), ($ia < $ib ? $b : $a); } } } foreach([ 0, 0, 0 ], [ 1, 1, -1 ], [ -1, -1, 1 ], [ 0x123, 1, -0x123 ], [ -0x123, -1, 0x123 ], [ max_sint, 1, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, -1, max_sint ], [ min_sint|0, 1, min_sint ], [ min_sint, -1, min_sint|0 ], [ min_sint|1, 1, undef ], [ min_sint|0x123, 1, undef ], [ max_uint, 1, undef ], ) { my($a, $sgn, $neg) = @$_; my $abs = (my $ta = $a) >= 0 ? $a : $neg; { is nint_sgn($a), $sgn; nint_is nint_abs($a), $abs; my $r = eval { nint_neg($a) }; if(defined $neg) { is $@, ""; nint_is $r, $neg; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_sint($a)) { is sint_sgn($a), $sgn; my $ra = eval { sint_abs($a) }; if(nint_is_sint($abs)) { is $@, ""; nint_is $ra, $abs; } else { like $@, qr/\Ainteger overflow/; } my $r = eval { sint_neg($a) }; if(defined($neg) && nint_is_sint($neg)) { is $@, ""; nint_is $r, $neg; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_uint($a)) { is uint_sgn($a), $sgn; nint_is uint_abs($a), $abs; my $r = eval { uint_neg($a) }; if(defined($neg) && nint_is_uint($neg)) { is $@, ""; nint_is $r, $neg; } else { like $@, qr/\Ainteger overflow/; } } } foreach([ undef, max_uint, min_sint ], [ undef, max_uint&~1, min_sint ], [ undef, max_uint, do { use integer; min_sint|1 } ], [ undef, min_sint|0, min_sint ], [ undef, min_sint|0, do { use integer; min_sint|2 } ], [ undef, max_uint, -1 ], [ undef, max_sint, min_sint ], [ undef, min_sint|0, do { use integer; min_sint|1 } ], [ undef, max_uint, 0 ], [ undef, max_sint&~1, min_sint ], [ undef, max_sint, do { use integer; min_sint|1 } ], [ undef, min_sint|0, do { use integer; min_sint|2 } ], [ undef, max_uint, 1 ], [ undef, 2, min_sint ], [ undef, 3, do { use integer; min_sint|1 } ], [ undef, max_sint, -3 ], [ undef, min_sint|1, -1 ], [ undef, min_sint|2, 0 ], [ undef, min_sint|3, 1 ], [ undef, max_uint&~1, max_sint&~3 ], [ undef, max_uint, max_sint&~2 ], [ undef, 1, min_sint ], [ undef, 2, do { use integer; min_sint|1 } ], [ undef, max_sint, -2 ], [ undef, min_sint|0, -1 ], [ undef, min_sint|1, 0 ], [ undef, min_sint|2, 1 ], [ undef, max_uint&~1, max_sint&~2 ], [ undef, max_uint, max_sint&~1 ], [ min_sint, min_sint, undef ], [ min_sint, do { use integer; min_sint|1 }, undef ], [ min_sint, -1, undef ], [ min_sint, 0, min_sint ], [ min_sint, 1, do { use integer; min_sint|1 } ], [ min_sint, max_sint, -1 ], [ min_sint, min_sint|0, 0 ], [ min_sint, min_sint|1, 1 ], [ min_sint, max_uint&~1, max_sint&~1 ], [ min_sint, max_uint, max_sint ], [ min_sint, undef, min_sint|0 ], [ min_sint, undef, max_uint&~1 ], [ min_sint, undef, max_uint ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|1 }, undef ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|2 }, undef ], [ do { use integer; min_sint|1 }, -2, undef ], [ do { use integer; min_sint|1 }, -1, min_sint ], [ do { use integer; min_sint|1 }, 0, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, 1, do { use integer; min_sint|2 } ], [ do { use integer; min_sint|1 }, max_sint&~1, -1 ], [ do { use integer; min_sint|1 }, max_sint, 0 ], [ do { use integer; min_sint|1 }, min_sint|0, 1 ], [ do { use integer; min_sint|1 }, max_uint&~2, max_sint&~1 ], [ do { use integer; min_sint|1 }, max_uint&~1, max_sint ], [ do { use integer; min_sint|1 }, max_uint, min_sint|0 ], [ do { use integer; min_sint|1 }, undef, max_uint&~1 ], [ do { use integer; min_sint|1 }, undef, max_uint ], [ do { use integer; min_sint|~(min_sint>>1) }, do { use integer; min_sint|~(min_sint>>1) }, undef ], [ do { use integer; min_sint|~(min_sint>>1) }, do { use integer; min_sint>>1 }, undef ], [ do { use integer; min_sint|~(min_sint>>1) }, do { use integer; (min_sint>>1)|1 }, min_sint ], [ do { use integer; min_sint|~(min_sint>>1) }, do { use integer; (min_sint>>1)|2 }, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|~(min_sint>>1) }, min_sint>>1, -1 ], [ do { use integer; min_sint|~(min_sint>>1) }, (min_sint>>1)|1, 0 ], [ do { use integer; min_sint|~(min_sint>>1) }, (min_sint>>1)|2, 1 ], [ do { use integer; min_sint|~(min_sint>>1) }, max_sint&~1, (max_sint>>1)&~2 ], [ do { use integer; min_sint|~(min_sint>>1) }, max_sint, (max_sint>>1)&~1 ], [ do { use integer; min_sint|~(min_sint>>1) }, min_sint|0, max_sint>>1 ], [ do { use integer; min_sint>>1 }, do { use integer; min_sint>>1 }, min_sint ], [ do { use integer; min_sint>>1 }, do { use integer; (min_sint>>1)|1 }, do { use integer; min_sint|1 } ], [ do { use integer; min_sint>>1 }, max_sint>>1, -1 ], [ do { use integer; min_sint>>1 }, min_sint>>1, 0 ], [ do { use integer; min_sint>>1 }, (min_sint>>1)|1, 1 ], [ do { use integer; min_sint>>1 }, max_sint&~1, (max_sint>>1)&~1 ], [ do { use integer; min_sint>>1 }, max_sint, max_sint>>1 ], [ do { use integer; min_sint>>1 }, min_sint|0, min_sint>>1, ], [ do { use integer; (min_sint>>1)|1 }, do { use integer; (min_sint>>1)|1 }, do { use integer; min_sint|2 } ], [ do { use integer; (min_sint>>1)|1 }, (max_sint>>1)&~1, -1 ], [ do { use integer; (min_sint>>1)|1 }, max_sint>>1, 0 ], [ do { use integer; (min_sint>>1)|1 }, min_sint>>1, 1 ], [ do { use integer; (min_sint>>1)|1 }, max_sint&~1, max_sint>>1 ], [ do { use integer; (min_sint>>1)|1 }, max_sint, min_sint>>1, ], [ do { use integer; (min_sint>>1)|1 }, min_sint|0, (min_sint>>1)|1 ], [ -0x123, -0x123, -0x246 ], [ -0x123, -1, -0x124 ], [ -0x123, 0, -0x123 ], [ -0x123, 1, -0x122 ], [ -0x123, 0x122, -1 ], [ -0x123, 0x123, 0 ], [ -0x123, 0x124, 1 ], [ -0x123, max_sint&~1, max_sint&~0x124 ], [ -0x123, max_sint, max_sint&~0x123 ], [ -0x123, min_sint|0, max_sint&~0x122 ], [ -0x123, min_sint|0x121, max_sint&~1 ], [ -0x123, min_sint|0x122, max_sint ], [ -0x123, min_sint|0x123, min_sint|0 ], [ -0x123, max_uint&~1, max_uint&~0x124 ], [ -0x123, max_uint, max_uint&~0x123 ], [ -0x123, undef, max_uint&~0x122 ], [ -0x123, undef, max_uint&~1 ], [ -0x123, undef, max_uint ], [ -1, -1, -2 ], [ -1, 0, -1 ], [ -1, 1, 0 ], [ -1, 0x123, 0x122 ], [ -1, max_sint&~1, max_sint&~2 ], [ -1, max_sint, max_sint&~1 ], [ -1, min_sint|0, max_sint ], [ -1, min_sint|1, min_sint|0 ], [ -1, max_uint&~1, max_uint&~2 ], [ -1, max_uint, max_uint&~1 ], [ -1, undef, max_uint ], [ 0, 0, 0 ], [ 0, 1, 1 ], [ 0, 0x123, 0x123 ], [ 0, max_sint&~1, max_sint&~1 ], [ 0, max_sint, max_sint ], [ 0, min_sint|0, min_sint|0 ], [ 0, max_uint&~1, max_uint&~1 ], [ 0, max_uint, max_uint ], [ 1, 1, 2 ], [ 1, 0x123, 0x124 ], [ 1, max_sint&~1, max_sint ], [ 1, max_sint, min_sint|0 ], [ 1, min_sint|0, min_sint|1 ], [ 1, max_uint&~1, max_uint ], [ 1, max_uint, undef ], [ 0x123, 0x123, 0x246 ], [ 0x123, max_sint&~0x124, max_sint&~1 ], [ 0x123, max_sint&~0x123, max_sint ], [ 0x123, max_sint&~0x122, min_sint|0 ], [ 0x123, max_sint&~1, min_sint|0x121 ], [ 0x123, max_sint, min_sint|0x122 ], [ 0x123, min_sint|0, min_sint|0x123 ], [ 0x123, max_uint&~0x124, max_uint&~1 ], [ 0x123, max_uint&~0x123, max_uint ], [ 0x123, max_uint&~0x122, undef ], [ 0x123, max_uint&~1, undef ], [ 0x123, max_uint, undef ], [ max_sint>>1, max_sint>>1, max_sint&~1 ], [ max_sint>>1, min_sint>>1, max_sint ], [ max_sint>>1, (min_sint>>1)|1, min_sint|0 ], [ max_sint>>1, max_uint&~1, undef ], [ max_sint>>1, max_uint, undef ], [ min_sint>>1, min_sint>>1, min_sint|0 ], [ min_sint>>1, (min_sint>>1)|1, min_sint|1 ], [ min_sint>>1, max_uint&~1, undef ], [ min_sint>>1, max_uint, undef ], [ max_sint&~1, max_sint&~1, max_uint&~3 ], [ max_sint&~1, max_sint, max_uint&~2 ], [ max_sint&~1, min_sint|0, max_uint&~1 ], [ max_sint&~1, min_sint|1, max_uint ], [ max_sint&~1, min_sint|2, undef ], [ max_sint&~1, max_uint&~1, undef ], [ max_sint&~1, max_uint, undef ], [ max_sint, max_sint, max_uint&~1 ], [ max_sint, min_sint|0, max_uint ], [ max_sint, min_sint|1, undef ], [ max_sint, max_uint&~1, undef ], [ max_sint, max_uint, undef ], [ min_sint|0, min_sint|0, undef ], [ min_sint|0, max_uint&~1, undef ], [ min_sint|0, max_uint, undef ], [ max_uint&~1, max_uint&~1, undef ], [ max_uint&~1, max_uint, undef ], [ max_uint, max_uint, undef ], ) { my($a, $b, $c) = @$_; if(defined($a) && defined($b)) { { my $r = eval { nint_add($a, $b) }; if(defined $c) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } $r = eval { nint_add($b, $a) }; if(defined $c) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_sint($a) && nint_is_sint($b)) { my $r = eval { sint_add($a, $b) }; if(defined($c) && nint_is_sint($c)) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } $r = eval { sint_add($b, $a) }; if(defined($c) && nint_is_sint($c)) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_uint($a) && nint_is_uint($b)) { my $r = eval { uint_add($a, $b) }; if(defined($c) && nint_is_uint($c)) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } $r = eval { uint_add($b, $a) }; if(defined($c) && nint_is_uint($c)) { is $@, ""; nint_is $r, $c; } else { like $@, qr/\Ainteger overflow/; } } } if(defined($a) && defined($c)) { { my $r = eval { nint_sub($c, $a) }; if(defined $b) { is $@, ""; nint_is $r, $b; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_sint($a) && nint_is_sint($c)) { my $r = eval { sint_sub($c, $a) }; if(defined($b) && nint_is_sint($b)) { is $@, ""; nint_is $r, $b; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_uint($a) && nint_is_uint($c)) { my $r = eval { uint_sub($c, $a) }; if(defined($b) && nint_is_uint($b)) { is $@, ""; nint_is $r, $b; } else { like $@, qr/\Ainteger overflow/; } } } if(defined($b) && defined($c)) { { my $r = eval { nint_sub($c, $b) }; if(defined $a) { is $@, ""; nint_is $r, $a; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_sint($b) && nint_is_sint($c)) { my $r = eval { sint_sub($c, $b) }; if(defined($a) && nint_is_sint($a)) { is $@, ""; nint_is $r, $a; } else { like $@, qr/\Ainteger overflow/; } } if(nint_is_uint($b) && nint_is_uint($c)) { my $r = eval { uint_sub($c, $b) }; if(defined($a) && nint_is_uint($a)) { is $@, ""; nint_is $r, $a; } else { like $@, qr/\Ainteger overflow/; } } } } 1; Data-Integer-0.007/t/fmt.t0000644000175000017500000000206313142153345013034 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 4*5 + 6*4; BEGIN { use_ok "Data::Integer", qw( nint_bits_as_sint nint_bits_as_uint sint_bits_as_uint uint_bits_as_sint max_sint max_uint min_sint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } foreach(0, 1, 0x123, max_sint&~1, max_sint) { nint_is nint_bits_as_sint($_), $_; nint_is nint_bits_as_uint($_), $_; nint_is sint_bits_as_uint($_), $_; nint_is uint_bits_as_sint($_), $_; } foreach([ -1, max_uint ], [ -2, max_uint&~1 ], [ do { use integer; min_sint|1 }, min_sint|1 ], [ min_sint, min_sint|0 ], ) { my($si, $ui) = @$_; nint_is nint_bits_as_sint($si), $si; nint_is nint_bits_as_sint($ui), $si; nint_is nint_bits_as_uint($si), $ui; nint_is nint_bits_as_uint($ui), $ui; nint_is sint_bits_as_uint($si), $ui; nint_is uint_bits_as_sint($ui), $si; } 1; Data-Integer-0.007/t/canon.t0000644000175000017500000000266313142153345013352 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 5*16 + 3*3; BEGIN { use_ok "Data::Integer", qw( nint sint uint nint_is_sint nint_is_uint min_sint max_sint max_uint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } foreach(0, +0.0, -0.0) { nint_is nint($_), 0; nint_is sint($_), 0; nint_is uint($_), 0; ok nint_is_sint($_); ok nint_is_uint($_); } foreach(1, 0x123, max_sint&~1, max_sint) { nint_is nint($_), $_; nint_is sint($_), $_; nint_is uint($_), $_; ok nint_is_sint($_); ok nint_is_uint($_); } foreach(-1, -0x123, do { use integer; min_sint|1 }, min_sint) { nint_is nint($_), $_; nint_is sint($_), $_; eval { uint($_) }; like $@, qr/\Anot an unsigned native integer/; ok nint_is_sint($_); ok !nint_is_uint($_); } foreach(min_sint|0, min_sint|1, min_sint|0x123, max_uint&~1, max_uint) { nint_is nint($_), $_; eval { sint($_) }; like $@, qr/\Anot a signed native integer/; nint_is uint($_), $_; ok !nint_is_sint($_); ok nint_is_uint($_); } foreach(0.5, max_uint*3/2, min_sint*3/2) { eval { nint($_) }; like $@, qr/\Anot a native integer/; eval { sint($_) }; like $@, qr/\Anot a signed native integer/; eval { uint($_) }; like $@, qr/\Anot an unsigned native integer/; } 1; Data-Integer-0.007/t/pod_syn.t0000644000175000017500000000023613142153345013721 0ustar rrrruse warnings; use strict; use Test::More; plan skip_all => "Test::Pod not available" unless eval "use Test::Pod 1.00; 1"; Test::Pod::all_pod_files_ok(); 1; Data-Integer-0.007/t/pod_cvg.t0000644000175000017500000000027313142153345013670 0ustar rrrruse warnings; use strict; use Test::More; plan skip_all => "Test::Pod::Coverage not available" unless eval "use Test::Pod::Coverage; 1"; Test::Pod::Coverage::all_pod_coverage_ok(); 1; Data-Integer-0.007/t/bitwise.t0000644000175000017500000001264613142153345013724 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 4*4 + (4*8 + 4*8 + 2*8)*2 + 4*8 + 4*8 + 4*5; BEGIN { use_ok "Data::Integer", qw( sint_not uint_not sint_and uint_and sint_nand uint_nand sint_andn uint_andn sint_or uint_or sint_nor uint_nor sint_orn uint_orn sint_xor uint_xor sint_nxor uint_nxor sint_mux uint_mux uint_bits_as_sint max_uint min_sint max_sint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } foreach([ 0, max_uint ], [ 1, max_uint&~1 ], [ 0x123, max_uint&~0x123 ], [ max_sint, min_sint|0 ], ) { my($ua, $ub) = @$_; nint_is uint_not($ua), $ub; nint_is uint_not($ub), $ua; my($sa, $sb) = (uint_bits_as_sint($ua), uint_bits_as_sint($ub)); nint_is sint_not($sa), $sb; nint_is sint_not($sb), $sa; } foreach([ 0, 0, 0 ], [ 0x1234, 0, 0 ], [ 0x1234, 0xf0f0, 0x1030 ], [ 0x1234, 0x0f0f, 0x0204 ], [ min_sint|0, max_sint, 0 ], [ min_sint|0x1234, max_sint, 0x1234 ], [ min_sint|0x1234, min_sint|0xf0f0, min_sint|0x1030 ], [ max_uint&~0xff, 0x1234, 0x1200 ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_and($ua, $ub), $ur; nint_is uint_and($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_and($sa, $sb), $sr; nint_is sint_and($sb, $sa), $sr; } foreach([ 0, 0, max_uint ], [ 0x1234, 0, max_uint ], [ 0x1234, 0xf0f0, max_uint&~0x1030 ], [ 0x1234, 0x0f0f, max_uint&~0x0204 ], [ min_sint|0, max_sint, max_uint ], [ min_sint|0x1234, max_sint, max_uint&~0x1234 ], [ min_sint|0x1234, min_sint|0xf0f0, max_sint&~0x1030 ], [ max_uint&~0xff, 0x1234, max_uint&~0x1200 ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_nand($ua, $ub), $ur; nint_is uint_nand($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_nand($sa, $sb), $sr; nint_is sint_nand($sb, $sa), $sr; } foreach([ 0, 0, 0 ], [ 0x1234, 0, 0x1234 ], [ 0x1234, 0xf0f0, 0x0204 ], [ 0x1234, 0x0f0f, 0x1030 ], [ min_sint|0, max_sint, min_sint|0 ], [ min_sint|0x1234, max_sint, min_sint|0 ], [ min_sint|0x1234, min_sint|0xf0f0, 0x0204 ], [ max_uint&~0xff, 0x1234, max_uint&~0x12ff ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_andn($ua, $ub), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_andn($sa, $sb), $sr; } foreach([ 0, 0, 0 ], [ 0x1234, 0, 0x1234 ], [ 0x1234, 0xf0f0, 0xf2f4 ], [ 0x1234, 0x0f0f, 0x1f3f ], [ min_sint|0, max_sint, max_uint ], [ min_sint|0x1234, 0x0f0f, min_sint|0x1f3f ], [ min_sint|0x1234, min_sint|0xf0f0, min_sint|0xf2f4 ], [ max_uint&~0xff, 0x1234, max_uint&~0xcb ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_or($ua, $ub), $ur; nint_is uint_or($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_or($sa, $sb), $sr; nint_is sint_or($sb, $sa), $sr; } foreach([ 0, 0, max_uint ], [ 0x1234, 0, max_uint&~0x1234 ], [ 0x1234, 0xf0f0, max_uint&~0xf2f4 ], [ 0x1234, 0x0f0f, max_uint&~0x1f3f ], [ min_sint|0, max_sint, 0 ], [ min_sint|0x1234, 0x0f0f, max_sint&~0x1f3f ], [ min_sint|0x1234, min_sint|0xf0f0, max_sint&~0xf2f4 ], [ max_uint&~0xff, 0x1234, 0xcb ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_nor($ua, $ub), $ur; nint_is uint_nor($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_nor($sa, $sb), $sr; nint_is sint_nor($sb, $sa), $sr; } foreach([ 0, 0, max_uint ], [ 0x1234, 0, max_uint ], [ 0x1234, 0xf0f0, max_uint&~0xe0c0 ], [ 0x1234, 0x0f0f, max_uint&~0x0d0b ], [ min_sint|0, max_sint, min_sint|0 ], [ min_sint|0x1234, 0x0f0f, max_uint&~0x0d0b ], [ min_sint|0x1234, min_sint|0xf0f0, max_uint&~0xe0c0 ], [ max_uint&~0xff, 0x1234, max_uint&~0x34 ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_orn($ua, $ub), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_orn($sa, $sb), $sr; } foreach([ 0, 0, 0 ], [ 0x1234, 0, 0x1234 ], [ 0x1234, 0xf0f0, 0xe2c4 ], [ 0x1234, 0x0f0f, 0x1d3b ], [ min_sint|0, max_sint, max_uint ], [ min_sint|0x1234, 0x0f0f, min_sint|0x1d3b ], [ min_sint|0x1234, min_sint|0xf0f0, 0xe2c4 ], [ max_uint&~0xff, 0x1234, max_uint&~0x12cb ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_xor($ua, $ub), $ur; nint_is uint_xor($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_xor($sa, $sb), $sr; nint_is sint_xor($sb, $sa), $sr; } foreach([ 0, 0, max_uint ], [ 0x1234, 0, max_uint&~0x1234 ], [ 0x1234, 0xf0f0, max_uint&~0xe2c4 ], [ 0x1234, 0x0f0f, max_uint&~0x1d3b ], [ min_sint|0, max_sint, 0 ], [ min_sint|0x1234, 0x0f0f, max_sint&~0x1d3b ], [ min_sint|0x1234, min_sint|0xf0f0, max_uint&~0xe2c4 ], [ max_uint&~0xff, 0x1234, 0x12cb ], ) { my($ua, $ub, $ur) = @$_; nint_is uint_nxor($ua, $ub), $ur; nint_is uint_nxor($ub, $ua), $ur; my($sa, $sb, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_nxor($sa, $sb), $sr; nint_is sint_nxor($sb, $sa), $sr; } foreach([ 0, 0, 0, 0 ], [ 0, min_sint|0x1234, 0x8765, 0x8765 ], [ max_uint, min_sint|0x1234, 0x8765, min_sint|0x1234 ], [ 0xf0f0, min_sint|0x1234, 0x8765, 0x1735 ], [ max_uint&~0xf0f0, min_sint|0x1234, 0x8765, min_sint|0x8264 ], ) { my($ua, $ub, $uc, $ur) = @$_; nint_is uint_mux($ua, $ub, $uc), $ur; nint_is uint_mux(~$ua, $uc, $ub), $ur; my($sa, $sb, $sc, $sr) = map { uint_bits_as_sint($_) } @$_; nint_is sint_mux($sa, $sb, $sc), $sr; nint_is sint_mux(do { use integer; ~$sa }, $sc, $sb), $sr; } 1; Data-Integer-0.007/t/shift.t0000644000175000017500000000575213142153345013373 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 2*21 + 1*17 + 1*17 + 4*21; BEGIN { use_ok "Data::Integer", qw( sint_shl uint_shl sint_shr uint_shr sint_rol uint_rol sint_ror uint_ror uint_bits_as_sint natint_bits min_sint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } my $bm1 = min_sint|0; my $bm2 = $bm1 >> 1; my $bm3 = $bm2 >> 1; my $bm4 = $bm3 >> 1; foreach([ 0, 0, 0 ], [ 0, 1, 0 ], [ 0, 16, 0 ], [ 0, natint_bits-1, 0 ], [ 1, 0, 1 ], [ 1, 1, 2 ], [ 1, 5, 32 ], [ 1, natint_bits-1, $bm1 ], [ 2, 0, 2 ], [ 2, 1, 4 ], [ 2, 5, 64 ], [ 2, natint_bits-2, $bm1 ], [ 2, natint_bits-1, 0 ], [ 3, 0, 3 ], [ 3, 1, 6 ], [ 3, 5, 96 ], [ 3, natint_bits-1, $bm1 ], [ 0x123, 0, 0x123 ], [ 0x123, 4, 0x1230 ], [ $bm1|0x123, 0, $bm1|0x123 ], [ $bm1|0x123, 4, 0x1230 ], ) { my($ua, $dist, $ur) = @$_; nint_is uint_shl($ua, $dist), $ur; my($sa, $sr) = (uint_bits_as_sint($ua), uint_bits_as_sint($ur)); nint_is sint_shl($sa, $dist), $sr; } foreach([ 0, 1, 0 ], [ 0, 16, 0 ], [ 0, natint_bits-1, 0 ], [ 1, 1, 0 ], [ 1, 16, 0 ], [ 1, natint_bits-1, 0 ], [ 0xa5c0, 1, 0x52e0 ], [ 0xa5c0, 4, 0xa5c ], [ 0xa5c0, 8, 0xa5 ], [ 0xa5c0, 12, 0xa ], [ 0xa5c0, 16, 0 ], [ 0xa5c0, natint_bits-1, 0 ], [ $bm1, 1, $bm2 ], [ $bm1|6, 1, $bm2|3 ], [ $bm1, natint_bits-2, 2 ], [ $bm1|6, natint_bits-2, 2 ], [ $bm1|6, natint_bits-1, 1 ], ) { my($ua, $dist, $ur) = @$_; nint_is uint_shr($ua, $dist), $ur; } foreach([ 0, 1, 0 ], [ 0, 16, 0 ], [ 0, natint_bits-1, 0 ], [ 1, 1, 0 ], [ 1, 16, 0 ], [ 1, natint_bits-1, 0 ], [ 0xa5c0, 1, 0x52e0 ], [ 0xa5c0, 4, 0xa5c ], [ 0xa5c0, 8, 0xa5 ], [ 0xa5c0, 12, 0xa ], [ 0xa5c0, 16, 0 ], [ 0xa5c0, natint_bits-1, 0 ], [ uint_bits_as_sint($bm1), 1, uint_bits_as_sint($bm1|$bm2) ], [ uint_bits_as_sint($bm1|6), 1, uint_bits_as_sint($bm1|$bm2|3) ], [ uint_bits_as_sint($bm1), natint_bits-2, -2 ], [ uint_bits_as_sint($bm1|6), natint_bits-2, -2 ], [ uint_bits_as_sint($bm1|6), natint_bits-1, -1 ], ) { my($sa, $dist, $sr) = @$_; nint_is sint_shr($sa, $dist), $sr; } foreach([ 0, 0, 0 ], [ 0, 1, 0 ], [ 0, 16, 0 ], [ 0, -1, 0 ], [ 1, 0, 1 ], [ 1, 1, 2 ], [ 1, 5, 32 ], [ 1, -1, $bm1 ], [ 2, 0, 2 ], [ 2, 1, 4 ], [ 2, 5, 64 ], [ 2, -1, 1 ], [ 2, -2, $bm1 ], [ 2, -3, $bm2 ], [ 0x123, 4, 0x1230 ], [ 0x123, -4, 0x12|$bm3|$bm4 ], [ $bm2|$bm4, 0, $bm2|$bm4 ], [ $bm2|$bm4, 1, $bm1|$bm3 ], [ $bm2|$bm4, 2, 1|$bm2 ], [ $bm2|$bm4, 3, 2|$bm1 ], [ $bm2|$bm4, 4, 5 ], ) { my($ua, $dist, $ur) = @$_; my $ldist = (natint_bits + $dist) % natint_bits; my $rdist = (natint_bits - $dist) % natint_bits; nint_is uint_rol($ua, $ldist), $ur; nint_is uint_ror($ua, $rdist), $ur; my($sa, $sr) = (uint_bits_as_sint($ua), uint_bits_as_sint($ur)); nint_is sint_rol($sa, $ldist), $sr; nint_is sint_ror($sa, $rdist), $sr; } 1; Data-Integer-0.007/t/const.t0000644000175000017500000000233213142153345013373 0ustar rrrruse warnings; use strict; use Test::More tests => 18; BEGIN { use_ok "Data::Integer", qw( natint_bits min_nint max_nint min_natint max_natint min_sint max_sint min_signed_natint max_signed_natint min_uint max_uint min_unsigned_natint max_unsigned_natint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } ok int(natint_bits) == natint_bits; ok natint_bits >= 16; use integer; my $min_sint = -1; for(my $i = natint_bits-1; $i--; ) { $min_sint += $min_sint; } ok $min_sint < 0; nint_is min_sint, $min_sint; nint_is min_signed_natint, $min_sint; nint_is min_nint, $min_sint; nint_is min_natint, $min_sint; nint_is min_sint + max_sint, -1; nint_is min_uint, 0; nint_is min_unsigned_natint, 0; my $max_sint = min_sint - 1; ok $max_sint > 0; nint_is max_sint, $max_sint; nint_is max_signed_natint, $max_sint; no integer; my $max_uint = $min_sint | $max_sint; nint_is max_uint, $max_uint; nint_is max_unsigned_natint, $max_uint; nint_is max_nint, $max_uint; nint_is max_natint, $max_uint; 1; Data-Integer-0.007/t/marith.t0000644000175000017500000005205313142153345013536 0ustar rrrruse warnings; use strict; use Test::More tests => 1 + 8*86 + 8*98 + 8*86 + 2*49 + 2*43 + 1*92 + 1*89; BEGIN { use_ok "Data::Integer", qw( sint_madd uint_madd sint_msub uint_msub sint_cadd uint_cadd sint_csub uint_csub sint_sadd uint_sadd sint_ssub uint_ssub min_sint max_sint max_uint uint_bits_as_sint ); } sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } foreach([ 0, 0, 0 ], [ 0, 1, 1 ], [ 0, 0x123, 0x123 ], [ 0, max_sint&~1, max_sint&~1 ], [ 0, max_sint, max_sint ], [ 0, min_sint|0, min_sint|0 ], [ 0, min_sint|1, min_sint|1 ], [ 0, max_uint&~0x122, max_uint&~0x122 ], [ 0, max_uint&~1, max_uint&~1 ], [ 0, max_uint, max_uint ], [ 1, 1, 2 ], [ 1, 0x123, 0x124 ], [ 1, max_sint&~1, max_sint ], [ 1, max_sint, min_sint|0 ], [ 1, min_sint|0, min_sint|1 ], [ 1, min_sint|1, min_sint|2 ], [ 1, max_uint&~0x122, max_uint&~0x121 ], [ 1, max_uint&~1, max_uint ], [ 1, max_uint, 0 ], [ 2, max_sint&~1, min_sint|0 ], [ 2, max_sint, min_sint|1 ], [ 2, min_sint|0, min_sint|2 ], [ 2, max_uint, 1 ], [ 3, max_sint&~1, min_sint|1 ], [ 0x121, max_uint&~0x122, max_uint&~1 ], [ 0x122, max_uint&~0x122, max_uint ], [ 0x123, 0x123, 0x246 ], [ 0x123, max_sint&~0x124, max_sint&~1 ], [ 0x123, max_sint&~0x123, max_sint ], [ 0x123, max_sint&~0x122, min_sint|0 ], [ 0x123, max_sint&~1, min_sint|0x121 ], [ 0x123, max_sint, min_sint|0x122 ], [ 0x123, min_sint|0, min_sint|0x123 ], [ 0x123, max_uint&~0x124, max_uint&~1 ], [ 0x123, max_uint&~0x123, max_uint ], [ 0x123, max_uint&~0x122, 0 ], [ 0x123, max_uint&~1, 0x121 ], [ 0x123, max_uint, 0x122 ], [ 0x124, max_uint&~0x122, 1 ], [ max_sint>>1, max_sint>>1, max_sint&~1 ], [ max_sint>>1, min_sint>>1, max_sint ], [ max_sint>>1, (min_sint>>1)|1, min_sint|0 ], [ max_sint>>1, max_uint&~1, (max_sint>>1)&~2 ], [ max_sint>>1, max_uint, (max_sint>>1)&~1 ], [ min_sint>>1, min_sint>>1, min_sint|0 ], [ min_sint>>1, (min_sint>>1)|1, min_sint|1 ], [ min_sint>>1, max_uint&~1, (max_sint>>1)&~1 ], [ min_sint>>1, max_uint, max_sint>>1 ], [ max_sint&~2, min_sint|1, max_uint&~1 ], [ max_sint&~1, max_sint&~1, max_uint&~3 ], [ max_sint&~1, max_sint, max_uint&~2 ], [ max_sint&~1, min_sint|0, max_uint&~1 ], [ max_sint&~1, min_sint|1, max_uint ], [ max_sint&~1, min_sint|2, 0 ], [ max_sint&~1, min_sint|3, 1 ], [ max_sint&~1, max_uint&~0x122, max_sint&~0x124 ], [ max_sint&~1, max_uint&~1, max_sint&~3 ], [ max_sint&~1, max_uint, max_sint&~2 ], [ max_sint, max_sint, max_uint&~1 ], [ max_sint, min_sint|0, max_uint ], [ max_sint, min_sint|1, 0 ], [ max_sint, min_sint|2, 1 ], [ max_sint, max_uint&~0x122, max_sint&~0x123 ], [ max_sint, max_uint&~1, max_sint&~2 ], [ max_sint, max_uint, max_sint&~1 ], [ min_sint|0, min_sint|0, 0 ], [ min_sint|0, min_sint|1, 1 ], [ min_sint|0, max_uint&~0x122, max_sint&~0x122 ], [ min_sint|0, max_uint&~1, max_sint&~1 ], [ min_sint|0, max_uint, max_sint ], [ min_sint|1, min_sint|1, 2 ], [ min_sint|1, min_sint|2, 3 ], [ min_sint|1, max_uint&~1, max_sint ], [ min_sint|1, max_uint&~2, max_sint&~1 ], [ min_sint|1, max_uint, min_sint|0 ], [ min_sint|2, max_uint&~1, min_sint|0 ], [ min_sint|2, max_uint, min_sint|1 ], [ min_sint|0x121, max_uint&~0x122, max_sint&~1 ], [ min_sint|0x122, max_uint&~0x122, max_sint ], [ min_sint|0x123, max_uint&~0x122, min_sint|0 ], [ max_uint&~0x122, max_uint&~0x122, max_uint&~0x245 ], [ max_uint&~0x122, max_uint&~1, max_uint&~0x124 ], [ max_uint&~0x122, max_uint, max_uint&~0x123 ], [ max_uint&~1, max_uint&~1, max_uint&~3 ], [ max_uint&~1, max_uint, max_uint&~2 ], [ max_uint, max_uint, max_uint&~1 ], ) { my($ua, $ub, $uc) = @$_; nint_is uint_madd($ua, $ub), $uc; nint_is uint_madd($ub, $ua), $uc; nint_is uint_msub($uc, $ua), $ub; nint_is uint_msub($uc, $ub), $ua; my($sa, $sb, $sc) = map { uint_bits_as_sint($_) } @$_; nint_is sint_madd($sa, $sb), $sc; nint_is sint_madd($sb, $sa), $sc; nint_is sint_msub($sc, $sa), $sb; nint_is sint_msub($sc, $sb), $sa; } foreach([ min_sint, min_sint, 0, -1, 0 ], [ min_sint, min_sint, 1, -1, 1 ], [ min_sint, do { use integer; min_sint|1 }, 0, -1, 1 ], [ min_sint, do { use integer; min_sint|1 }, 1, -1, 2 ], [ min_sint, -2, 0, -1, max_sint&~1 ], [ min_sint, -2, 1, -1, max_sint ], [ min_sint, -1, 0, -1, max_sint ], [ min_sint, -1, 1, 0, min_sint ], [ min_sint, 0, 0, 0, min_sint ], [ min_sint, 0, 1, 0, do { use integer; min_sint|1 } ], [ min_sint, 1, 0, 0, do { use integer; min_sint|1 } ], [ min_sint, 1, 1, 0, do { use integer; min_sint|2 } ], [ min_sint, max_sint&~1, 0, 0, -2 ], [ min_sint, max_sint&~1, 1, 0, -1 ], [ min_sint, max_sint, 0, 0, -1 ], [ min_sint, max_sint, 1, 0, 0 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|1 }, 0, -1, 2 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|1 }, 1, -1, 3 ], [ do { use integer; min_sint|1 }, -2, 0, -1, max_sint ], [ do { use integer; min_sint|1 }, -2, 1, 0, min_sint ], [ do { use integer; min_sint|1 }, -1, 0, 0, min_sint ], [ do { use integer; min_sint|1 }, -1, 1, 0, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, 0, 0, 0, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, 0, 1, 0, do { use integer; min_sint|2 } ], [ do { use integer; min_sint|1 }, 1, 0, 0, do { use integer; min_sint|2 } ], [ do { use integer; min_sint|1 }, 1, 1, 0, do { use integer; min_sint|3 } ], [ do { use integer; min_sint|1 }, max_sint&~1, 0, 0, -1 ], [ do { use integer; min_sint|1 }, max_sint&~1, 1, 0, 0 ], [ do { use integer; min_sint|1 }, max_sint, 0, 0, 0 ], [ do { use integer; min_sint|1 }, max_sint, 1, 0, 1 ], [ -2, -2, 0, 0, -4 ], [ -2, -2, 1, 0, -3 ], [ -2, -1, 0, 0, -3 ], [ -2, -1, 1, 0, -2 ], [ -2, 0, 0, 0, -2 ], [ -2, 0, 1, 0, -1 ], [ -2, 1, 0, 0, -1 ], [ -2, 1, 1, 0, 0 ], [ -2, 2, 0, 0, 0 ], [ -2, 2, 1, 0, 1 ], [ -2, 3, 0, 0, 1 ], [ -2, 3, 1, 0, 2 ], [ -2, max_sint&~1, 0, 0, max_sint&~3 ], [ -2, max_sint&~1, 1, 0, max_sint&~2 ], [ -2, max_sint, 0, 0, max_sint&~2 ], [ -2, max_sint, 1, 0, max_sint&~1 ], [ -1, -1, 0, 0, -2 ], [ -1, -1, 1, 0, -1 ], [ -1, 0, 0, 0, -1 ], [ -1, 0, 1, 0, 0 ], [ -1, 1, 0, 0, 0 ], [ -1, 1, 1, 0, 1 ], [ -1, 2, 0, 0, 1 ], [ -1, 2, 1, 0, 2 ], [ -1, max_sint&~1, 0, 0, max_sint&~2 ], [ -1, max_sint&~1, 1, 0, max_sint&~1 ], [ -1, max_sint, 0, 0, max_sint&~1 ], [ -1, max_sint, 1, 0, max_sint ], [ 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 1, 1, 0, 2 ], [ 0, 2, 0, 0, 2 ], [ 0, 2, 1, 0, 3 ], [ 0, max_sint&~1, 0, 0, max_sint&~1 ], [ 0, max_sint&~1, 1, 0, max_sint ], [ 0, max_sint, 0, 0, max_sint ], [ 0, max_sint, 1, 1, min_sint ], [ 1, 1, 0, 0, 2 ], [ 1, 1, 1, 0, 3 ], [ 1, 2, 0, 0, 3 ], [ 1, 2, 1, 0, 4 ], [ 1, max_sint&~1, 0, 0, max_sint ], [ 1, max_sint&~1, 1, 1, min_sint ], [ 1, max_sint, 0, 1, min_sint ], [ 1, max_sint, 1, 1, do { use integer; min_sint|1 } ], [ 2, 2, 0, 0, 4 ], [ 2, 2, 1, 0, 5 ], [ 2, 3, 0, 0, 5 ], [ 2, 3, 1, 0, 6 ], [ 2, max_sint&~2, 0, 0, max_sint ], [ 2, max_sint&~2, 1, 1, min_sint ], [ 2, max_sint&~1, 0, 1, min_sint ], [ 2, max_sint&~1, 1, 1, do { use integer; min_sint|1 } ], [ 2, max_sint, 0, 1, do { use integer; min_sint|1 } ], [ 2, max_sint, 1, 1, do { use integer; min_sint|2 } ], [ max_sint&~2, max_sint&~2, 0, 1, -6 ], [ max_sint&~2, max_sint&~2, 1, 1, -5 ], [ max_sint&~2, max_sint&~1, 0, 1, -5 ], [ max_sint&~2, max_sint&~1, 1, 1, -4 ], [ max_sint&~2, max_sint, 0, 1, -4 ], [ max_sint&~2, max_sint, 1, 1, -3 ], [ max_sint&~1, max_sint&~1, 0, 1, -4 ], [ max_sint&~1, max_sint&~1, 1, 1, -3 ], [ max_sint&~1, max_sint, 0, 1, -3 ], [ max_sint&~1, max_sint, 1, 1, -2 ], [ max_sint, max_sint, 0, 1, -2 ], [ max_sint, max_sint, 1, 1, -1 ], ) { my($a, $b, $cin, $cout, $c) = @$_; my($arc, $arv); ($arc, $arv) = sint_cadd($a, $b, $cin); nint_is $arc, $cout; nint_is $arv, $c; ($arc, $arv) = sint_cadd($b, $a, $cin); nint_is $arc, $cout; nint_is $arv, $c; ($arc, $arv) = sint_csub($c, $a, $cin); nint_is $arc, $cout; nint_is $arv, $b; ($arc, $arv) = sint_csub($c, $b, $cin); nint_is $arc, $cout; nint_is $arv, $a; } foreach([ 0, 0, 0, 0, 0 ], [ 0, 0, 1, 0, 1 ], [ 0, 1, 0, 0, 1 ], [ 0, 1, 1, 0, 2 ], [ 0, 0x123, 0, 0, 0x123 ], [ 0, 0x123, 1, 0, 0x124 ], [ 0, max_sint, 0, 0, max_sint ], [ 0, max_sint, 1, 0, min_sint|0 ], [ 0, min_sint|0, 0, 0, min_sint|0 ], [ 0, min_sint|0, 1, 0, min_sint|1 ], [ 0, min_sint|1, 0, 0, min_sint|1 ], [ 0, min_sint|1, 1, 0, min_sint|2 ], [ 0, max_uint&~1, 0, 0, max_uint&~1 ], [ 0, max_uint&~1, 1, 0, max_uint ], [ 0, max_uint, 0, 0, max_uint ], [ 0, max_uint, 1, 1, 0 ], [ 1, 1, 0, 0, 2 ], [ 1, 1, 1, 0, 3 ], [ 1, 0x123, 0, 0, 0x124 ], [ 1, 0x123, 1, 0, 0x125 ], [ 1, max_sint&~1, 0, 0, max_sint ], [ 1, max_sint&~1, 1, 0, min_sint|0 ], [ 1, max_sint, 0, 0, min_sint|0 ], [ 1, max_sint, 1, 0, min_sint|1 ], [ 1, min_sint|0, 0, 0, min_sint|1 ], [ 1, min_sint|0, 1, 0, min_sint|2 ], [ 1, min_sint|1, 0, 0, min_sint|2 ], [ 1, min_sint|1, 1, 0, min_sint|3 ], [ 1, max_uint&~2, 0, 0, max_uint&~1 ], [ 1, max_uint&~2, 1, 0, max_uint ], [ 1, max_uint&~1, 0, 0, max_uint ], [ 1, max_uint&~1, 1, 1, 0 ], [ 1, max_uint, 0, 1, 0 ], [ 1, max_uint, 1, 1, 1 ], [ 0x123, 0x123, 0, 0, 0x246 ], [ 0x123, 0x123, 1, 0, 0x247 ], [ 0x123, max_sint, 0, 0, min_sint|0x122 ], [ 0x123, max_sint, 1, 0, min_sint|0x123 ], [ 0x123, min_sint|0, 0, 0, min_sint|0x123 ], [ 0x123, min_sint|0, 1, 0, min_sint|0x124 ], [ 0x123, min_sint|1, 0, 0, min_sint|0x124 ], [ 0x123, min_sint|1, 1, 0, min_sint|0x125 ], [ 0x123, max_uint, 0, 1, 0x122 ], [ 0x123, max_uint, 1, 1, 0x123 ], [ max_sint&~1, max_sint&~1, 0, 0, max_uint&~3 ], [ max_sint&~1, max_sint&~1, 1, 0, max_uint&~2 ], [ max_sint&~1, max_sint, 0, 0, max_uint&~2 ], [ max_sint&~1, max_sint, 1, 0, max_uint&~1 ], [ max_sint&~1, min_sint|0, 0, 0, max_uint&~1 ], [ max_sint&~1, min_sint|0, 1, 0, max_uint ], [ max_sint&~1, min_sint|1, 0, 0, max_uint ], [ max_sint&~1, min_sint|1, 1, 1, 0 ], [ max_sint&~1, min_sint|2, 0, 1, 0 ], [ max_sint&~1, min_sint|2, 1, 1, 1 ], [ max_sint&~1, min_sint|3, 0, 1, 1 ], [ max_sint&~1, min_sint|3, 1, 1, 2 ], [ max_sint&~1, max_uint, 0, 1, max_sint&~2 ], [ max_sint&~1, max_uint, 1, 1, max_sint&~1 ], [ max_sint, max_sint, 0, 0, max_uint&~1 ], [ max_sint, max_sint, 1, 0, max_uint ], [ max_sint, min_sint|0, 0, 0, max_uint ], [ max_sint, min_sint|0, 1, 1, 0 ], [ max_sint, min_sint|1, 0, 1, 0 ], [ max_sint, min_sint|1, 1, 1, 1 ], [ max_sint, min_sint|2, 0, 1, 1 ], [ max_sint, min_sint|2, 1, 1, 2 ], [ max_sint, max_uint, 0, 1, max_sint&~1 ], [ max_sint, max_uint, 1, 1, max_sint ], [ min_sint|0, min_sint|0, 0, 1, 0 ], [ min_sint|0, min_sint|0, 1, 1, 1 ], [ min_sint|0, min_sint|1, 0, 1, 1 ], [ min_sint|0, min_sint|1, 1, 1, 2 ], [ min_sint|0, max_uint, 0, 1, max_sint ], [ min_sint|0, max_uint, 1, 1, min_sint|0 ], [ min_sint|1, min_sint|0, 0, 1, 1 ], [ min_sint|1, min_sint|0, 1, 1, 2 ], [ min_sint|1, min_sint|1, 0, 1, 2 ], [ min_sint|1, min_sint|1, 1, 1, 3 ], [ min_sint|1, max_uint, 0, 1, min_sint|0 ], [ min_sint|1, max_uint, 1, 1, min_sint|1 ], [ max_uint&~1, max_uint&~1, 0, 1, max_uint&~3 ], [ max_uint&~1, max_uint&~1, 1, 1, max_uint&~2 ], [ max_uint&~1, max_uint, 0, 1, max_uint&~2 ], [ max_uint&~1, max_uint, 1, 1, max_uint&~1 ], [ max_uint, max_uint, 0, 1, max_uint&~1 ], [ max_uint, max_uint, 1, 1, max_uint ], ) { my($a, $b, $cin, $cout, $c) = @$_; my($arc, $arv); ($arc, $arv) = uint_cadd($a, $b, $cin); nint_is $arc, $cout; nint_is $arv, $c; ($arc, $arv) = uint_cadd($b, $a, $cin); nint_is $arc, $cout; nint_is $arv, $c; ($arc, $arv) = uint_csub($c, $a, $cin); nint_is $arc, $cout; nint_is $arv, $b; ($arc, $arv) = uint_csub($c, $b, $cin); nint_is $arc, $cout; nint_is $arv, $a; } foreach([ min_sint, min_sint, min_sint ], [ min_sint, do { use integer; min_sint|1 }, min_sint ], [ min_sint, -2, min_sint ], [ min_sint, -1, min_sint ], [ min_sint, 0, min_sint ], [ min_sint, 1, do { use integer; min_sint|1 } ], [ min_sint, max_sint&~1, -2 ], [ min_sint, max_sint, -1 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|1 }, min_sint ], [ do { use integer; min_sint|1 }, -2, min_sint ], [ do { use integer; min_sint|1 }, -1, min_sint ], [ do { use integer; min_sint|1 }, 0, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, 1, do { use integer; min_sint|2 } ], [ do { use integer; min_sint|1 }, max_sint&~1, -1 ], [ do { use integer; min_sint|1 }, max_sint, 0 ], [ -2, -2, -4 ], [ -2, -1, -3 ], [ -2, 0, -2 ], [ -2, 1, -1 ], [ -2, 2, 0 ], [ -2, 3, 1 ], [ -2, max_sint&~1, max_sint&~3 ], [ -2, max_sint, max_sint&~2 ], [ -1, -1, -2 ], [ -1, 0, -1 ], [ -1, 1, 0 ], [ -1, 2, 1 ], [ -1, max_sint&~1, max_sint&~2 ], [ -1, max_sint, max_sint&~1 ], [ 0, 0, 0 ], [ 0, 1, 1 ], [ 0, 2, 2 ], [ 0, max_sint&~1, max_sint&~1 ], [ 0, max_sint, max_sint ], [ 1, 1, 2 ], [ 1, 2, 3 ], [ 1, max_sint&~1, max_sint ], [ 1, max_sint, max_sint ], [ 2, 2, 4 ], [ 2, 3, 5 ], [ 2, max_sint&~2, max_sint ], [ 2, max_sint&~1, max_sint ], [ 2, max_sint, max_sint ], [ max_sint&~2, max_sint&~2, max_sint ], [ max_sint&~2, max_sint&~1, max_sint ], [ max_sint&~2, max_sint, max_sint ], [ max_sint&~1, max_sint&~1, max_sint ], [ max_sint&~1, max_sint, max_sint ], [ max_sint, max_sint, max_sint ], ) { my($a, $b, $c) = @$_; nint_is sint_sadd($a, $b), $c; nint_is sint_sadd($b, $a), $c; } foreach([ 0, 0, 0 ], [ 0, 1, 1 ], [ 0, 0x123, 0x123 ], [ 0, max_sint, max_sint ], [ 0, min_sint|0, min_sint|0 ], [ 0, min_sint|1, min_sint|1 ], [ 0, max_uint&~1, max_uint&~1 ], [ 0, max_uint, max_uint ], [ 1, 1, 2 ], [ 1, 0x123, 0x124 ], [ 1, max_sint&~1, max_sint ], [ 1, max_sint, min_sint|0 ], [ 1, min_sint|0, min_sint|1 ], [ 1, min_sint|1, min_sint|2 ], [ 1, max_uint&~2, max_uint&~1 ], [ 1, max_uint&~1, max_uint ], [ 1, max_uint, max_uint ], [ 0x123, 0x123, 0x246 ], [ 0x123, max_sint, min_sint|0x122 ], [ 0x123, min_sint|0, min_sint|0x123 ], [ 0x123, min_sint|1, min_sint|0x124 ], [ 0x123, max_uint, max_uint ], [ max_sint&~1, max_sint&~1, max_uint&~3 ], [ max_sint&~1, max_sint, max_uint&~2 ], [ max_sint&~1, min_sint|0, max_uint&~1 ], [ max_sint&~1, min_sint|1, max_uint ], [ max_sint&~1, min_sint|2, max_uint ], [ max_sint&~1, min_sint|3, max_uint ], [ max_sint&~1, max_uint, max_uint ], [ max_sint, max_sint, max_uint&~1 ], [ max_sint, min_sint|0, max_uint ], [ max_sint, min_sint|1, max_uint ], [ max_sint, min_sint|2, max_uint ], [ max_sint, max_uint, max_uint ], [ min_sint|0, min_sint|0, max_uint ], [ min_sint|0, min_sint|1, max_uint ], [ min_sint|0, max_uint, max_uint ], [ min_sint|1, min_sint|0, max_uint ], [ min_sint|1, min_sint|1, max_uint ], [ min_sint|1, max_uint, max_uint ], [ max_uint&~1, max_uint&~1, max_uint ], [ max_uint&~1, max_uint, max_uint ], [ max_uint, max_uint, max_uint ], ) { my($a, $b, $c) = @$_; nint_is uint_sadd($a, $b), $c; nint_is uint_sadd($b, $a), $c; } foreach([ min_sint, min_sint, 0 ], [ min_sint, do { use integer; min_sint|1 }, -1 ], [ min_sint, do { use integer; min_sint>>1 }, do { use integer; min_sint>>1 } ], [ min_sint, -0x123, do { use integer; min_sint|0x123 } ], [ min_sint, -1, do { use integer; min_sint|1 } ], [ min_sint, 0, min_sint ], [ min_sint, 1, min_sint ], [ min_sint, 0x123, min_sint ], [ min_sint, max_sint&~1, min_sint ], [ min_sint, max_sint, min_sint ], [ do { use integer; min_sint|1 }, min_sint, 1 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|1 }, 0 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint|2 }, -1 ], [ do { use integer; min_sint|1 }, do { use integer; min_sint>>1 }, do { use integer; (min_sint>>1)|1 } ], [ do { use integer; min_sint|1 }, -0x123, do { use integer; min_sint|0x124 } ], [ do { use integer; min_sint|1 }, -1, do { use integer; min_sint|2 } ], [ do { use integer; min_sint|1 }, 0, do { use integer; min_sint|1 } ], [ do { use integer; min_sint|1 }, 1, min_sint ], [ do { use integer; min_sint|1 }, 2, min_sint ], [ do { use integer; min_sint|1 }, 0x123, min_sint ], [ do { use integer; min_sint|1 }, max_sint&~1, min_sint ], [ do { use integer; min_sint|1 }, max_sint, min_sint ], [ -2, min_sint, max_sint&~1 ], [ -2, do { use integer; min_sint|1 }, max_sint&~2 ], [ -2, -0x123, 0x121 ], [ -2, -1, -1 ], [ -2, 0, -2 ], [ -2, 1, -3 ], [ -2, 0x123, -0x125 ], [ -2, max_sint&~2, do { use integer; min_sint|1 } ], [ -2, max_sint&~1, min_sint ], [ -2, max_sint, min_sint ], [ -1, min_sint, max_sint ], [ -1, do { use integer; min_sint|1 }, max_sint&~1 ], [ -1, -0x123, 0x122 ], [ -1, -1, 0 ], [ -1, 0, -1 ], [ -1, 1, -2 ], [ -1, 0x123, -0x124 ], [ -1, max_sint&~2, do { use integer; min_sint|2 } ], [ -1, max_sint&~1, do { use integer; min_sint|1 } ], [ -1, max_sint, min_sint ], [ 0, min_sint, max_sint ], [ 0, do { use integer; min_sint|1 }, max_sint ], [ 0, do { use integer; min_sint|2 }, max_sint&~1 ], [ 0, -0x123, 0x123 ], [ 0, -1, 1 ], [ 0, 0, 0 ], [ 0, 1, -1 ], [ 0, 0x123, -0x123 ], [ 0, max_sint&~2, do { use integer; min_sint|3 } ], [ 0, max_sint&~1, do { use integer; min_sint|2 } ], [ 0, max_sint, do { use integer; min_sint|1 } ], [ 1, min_sint, max_sint ], [ 1, do { use integer; min_sint|1 }, max_sint ], [ 1, do { use integer; min_sint|2 }, max_sint ], [ 1, do { use integer; min_sint|3 }, max_sint&~1 ], [ 1, -0x123, 0x124 ], [ 1, -1, 2 ], [ 1, 0, 1 ], [ 1, 1, 0 ], [ 1, 0x123, -0x122 ], [ 1, max_sint&~2, do { use integer; min_sint|4 } ], [ 1, max_sint&~1, do { use integer; min_sint|3 } ], [ 1, max_sint, do { use integer; min_sint|2 } ], [ 2, min_sint, max_sint ], [ 2, do { use integer; min_sint|3 }, max_sint ], [ 2, -0x123, 0x125 ], [ 2, -1, 3 ], [ 2, 0, 2 ], [ 2, 1, 1 ], [ 2, 0x123, -0x121 ], [ 2, max_sint&~1, do { use integer; min_sint|4 } ], [ 2, max_sint, do { use integer; min_sint|3 } ], [ max_sint&~1, min_sint, max_sint ], [ max_sint&~1, do { use integer; min_sint|3 }, max_sint ], [ max_sint&~1, -0x123, max_sint ], [ max_sint&~1, -1, max_sint ], [ max_sint&~1, 0, max_sint&~1 ], [ max_sint&~1, 1, max_sint&~2 ], [ max_sint&~1, 0x123, max_sint&~0x124 ], [ max_sint&~1, max_sint&~1, 0 ], [ max_sint&~1, max_sint, -1 ], [ max_sint, min_sint, max_sint ], [ max_sint, do { use integer; min_sint|3 }, max_sint ], [ max_sint, -0x123, max_sint ], [ max_sint, -1, max_sint ], [ max_sint, 0, max_sint ], [ max_sint, 1, max_sint&~1 ], [ max_sint, 0x123, max_sint&~0x123 ], [ max_sint, max_sint&~1, 1 ], [ max_sint, max_sint, 0 ], ) { my($a, $b, $c) = @$_; nint_is sint_ssub($a, $b), $c; } foreach([ 0, 0, 0 ], [ 0, 1, 0 ], [ 0, 0x123, 0 ], [ 0, max_sint&~1, 0 ], [ 0, max_sint, 0 ], [ 0, min_sint|0, 0 ], [ 0, min_sint|1, 0 ], [ 0, max_uint&~1, 0 ], [ 0, max_uint, 0 ], [ 1, 0, 1 ], [ 1, 1, 0 ], [ 1, 0x123, 0 ], [ 1, max_sint&~1, 0 ], [ 1, max_sint, 0 ], [ 1, min_sint|0, 0 ], [ 1, min_sint|1, 0 ], [ 1, max_uint&~1, 0 ], [ 1, max_uint, 0 ], [ 0x123, 0, 0x123 ], [ 0x123, 1, 0x122 ], [ 0x123, 0x122, 1 ], [ 0x123, 0x123, 0 ], [ 0x123, 0x124, 0 ], [ 0x123, max_sint&~1, 0 ], [ 0x123, max_sint, 0 ], [ 0x123, min_sint|0, 0 ], [ 0x123, min_sint|1, 0 ], [ 0x123, max_uint&~1, 0 ], [ 0x123, max_uint, 0 ], [ max_sint&~1, 0, max_sint&~1 ], [ max_sint&~1, 1, max_sint&~2 ], [ max_sint&~1, 0x123, max_sint&~0x124 ], [ max_sint&~1, max_sint&~2, 1 ], [ max_sint&~1, max_sint&~1, 0 ], [ max_sint&~1, max_sint, 0 ], [ max_sint&~1, min_sint|0, 0 ], [ max_sint&~1, min_sint|1, 0 ], [ max_sint&~1, max_uint&~1, 0 ], [ max_sint&~1, max_uint, 0 ], [ max_sint, 0, max_sint ], [ max_sint, 1, max_sint&~1 ], [ max_sint, 0x123, max_sint&~0x123 ], [ max_sint, max_sint&~1, 1 ], [ max_sint, max_sint, 0 ], [ max_sint, min_sint|0, 0 ], [ max_sint, min_sint|1, 0 ], [ max_sint, max_uint&~1, 0 ], [ max_sint, max_uint, 0 ], [ min_sint|0, 0, min_sint|0 ], [ min_sint|0, 1, max_sint ], [ min_sint|0, 0x123, max_sint&~0x122 ], [ min_sint|0, max_sint&~1, 2 ], [ min_sint|0, max_sint, 1 ], [ min_sint|0, min_sint|0, 0 ], [ min_sint|0, min_sint|1, 0 ], [ min_sint|0, max_uint&~1, 0 ], [ min_sint|0, max_uint, 0 ], [ min_sint|1, 0, min_sint|1 ], [ min_sint|1, 1, min_sint|0 ], [ min_sint|1, 2, max_sint ], [ min_sint|1, 0x123, max_sint&~0x121 ], [ min_sint|1, max_sint&~1, 3 ], [ min_sint|1, max_sint, 2 ], [ min_sint|1, min_sint|0, 1 ], [ min_sint|1, min_sint|1, 0 ], [ min_sint|1, max_uint&~1, 0 ], [ min_sint|1, max_uint, 0 ], [ max_uint&~1, 0, max_uint&~1 ], [ max_uint&~1, 1, max_uint&~2 ], [ max_uint&~1, 2, max_uint&~3 ], [ max_uint&~1, 0x123, max_uint&~0x124 ], [ max_uint&~1, max_sint&~1, min_sint|0 ], [ max_uint&~1, max_sint, max_sint ], [ max_uint&~1, min_sint|0, max_sint&~1 ], [ max_uint&~1, min_sint|1, max_sint&~2 ], [ max_uint&~1, max_uint&~2, 1 ], [ max_uint&~1, max_uint&~1, 0 ], [ max_uint&~1, max_uint, 0 ], [ max_uint, 0, max_uint ], [ max_uint, 1, max_uint&~1 ], [ max_uint, 2, max_uint&~2 ], [ max_uint, 0x123, max_uint&~0x123 ], [ max_uint, max_sint&~1, min_sint|1 ], [ max_uint, max_sint, min_sint|0 ], [ max_uint, min_sint|0, max_sint ], [ max_uint, min_sint|1, max_sint&~1 ], [ max_uint, max_uint&~2, 2 ], [ max_uint, max_uint&~1, 1 ], [ max_uint, max_uint, 0 ], ) { my($a, $b, $c) = @$_; nint_is uint_ssub($a, $b), $c; } 1; Data-Integer-0.007/t/hex.t0000644000175000017500000001030613142153345013031 0ustar rrrruse warnings; use strict; use Test::More tests => 116; BEGIN { use_ok "Data::Integer", qw(natint_hex hex_natint natint_bits); } like natint_hex(0), qr/\A\+0x0{4,}\z/; like natint_hex(+0.0), qr/\A\+0x0{4,}\z/; like natint_hex(-0.0), qr/\A\+0x0{4,}\z/; like natint_hex(0x1), qr/\A\+0x0+1\z/; like natint_hex(0xf), qr/\A\+0x0+f\z/; like natint_hex(0x12ab), qr/\A\+0x0*12ab\z/; like natint_hex(-0x1), qr/\A\-0x0+1\z/; like natint_hex(-0xf), qr/\A\-0x0+f\z/; like natint_hex(-0x12ab), qr/\A\-0x0*12ab\z/; sub nint_is($$) { my($tval, $cval) = @_; my $tval0 = $tval; ok defined($tval) && ref(\$tval) eq "SCALAR" && int($tval0) == $tval0 && "$tval" eq "$cval" && ((my $tval1 = $tval) <=> 0) == ((my $cval1 = $cval) <=> 0) && do { use integer; $tval == $cval }, "$tval match $cval"; } sub zpat($) { my($z) = @_; sprintf("%+.f%+.f%+.f", $z, -$z, - -$z) } my $z; $z = hex_natint("0"); is zpat($z), "+0+0+0"; nint_is $z, 0; $z = hex_natint("+0"); is zpat($z), "+0+0+0"; nint_is $z, 0; $z = hex_natint("-0"); is zpat($z), "+0+0+0"; nint_is $z, 0; nint_is hex_natint("b"), 11; nint_is hex_natint("B"), 11; nint_is hex_natint("00B"), 11; nint_is hex_natint("0x0012"), 18; nint_is hex_natint("0012"), 18; nint_is hex_natint("0x12"), 18; nint_is hex_natint("12"), 18; nint_is hex_natint("+0x0012"), 18; nint_is hex_natint("+0012"), 18; nint_is hex_natint("+0x12"), 18; nint_is hex_natint("+12"), 18; nint_is hex_natint("-0x0012"), -18; nint_is hex_natint("-0012"), -18; nint_is hex_natint("-0x12"), -18; nint_is hex_natint("-12"), -18; sub uns_shr($$) { no integer; $_[0] >> $_[1] } sub sig_shr($$) { use integer; $_[0] >> $_[1] } sub uns_shl($$) { no integer; $_[0] << $_[1] } sub sig_shl($$) { use integer; $_[0] << $_[1] } sub negate($) { use integer; -$_[0] } my $tail_digits = uns_shr(natint_bits - 2, 2); my $tval = uns_shl(1, natint_bits - 2) | 3; my $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint($head_digit.("0" x ($tail_digits-1))."3"), $tval; $tval = ~uns_shl(1, natint_bits - 1); $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint($head_digit.("f" x $tail_digits)), $tval; $tail_digits = uns_shr(natint_bits - 1, 2); $tval = uns_shl(1, natint_bits - 1); $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint($head_digit.("0" x $tail_digits)), $tval; $tval = uns_shl(~uns_shl(1, natint_bits - 1), 1); $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint($head_digit.("f" x ($tail_digits-1))."e"), $tval; $tval = uns_shl(~uns_shl(1, natint_bits - 1), 1) | 1; $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint($head_digit.("f" x $tail_digits)), $tval; for(my $i = 1; $i != 16; $i++) { my $over_digit = sprintf("%x", hex($head_digit) + $i); eval { hex_natint($over_digit.("0" x $tail_digits)) }; like $@, qr/\Ainteger value too large/; eval { hex_natint($over_digit.("0" x ($tail_digits-1))."1") }; like $@, qr/\Ainteger value too large/; eval { hex_natint($over_digit.("f" x $tail_digits)) }; like $@, qr/\Ainteger value too large/; } for(my $i = 16; $i <= 256; $i += 16) { my $over_digit = sprintf("%x", hex($head_digit) + $i); eval { hex_natint($over_digit.("0" x $tail_digits)) }; like $@, qr/\Ainteger value too large/; } $tail_digits = uns_shr(natint_bits - 2, 2); $tval = uns_shl(1, natint_bits - 2) | 3; $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint("-".$head_digit.("0" x ($tail_digits-1))."3"), negate($tval); $tval = ~uns_shl(1, natint_bits - 1); $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint("-".$head_digit.("f" x $tail_digits)), negate($tval); $tail_digits = uns_shr(natint_bits - 1, 2); $tval = sig_shl(1, natint_bits - 1); $head_digit = sprintf("%x", uns_shr($tval, uns_shl($tail_digits, 2))); nint_is hex_natint("-".$head_digit.("0" x $tail_digits)), $tval; eval { hex_natint("-".$head_digit.("0" x ($tail_digits-1))."1") }; like $@, qr/\Ainteger value too large/; for(my $i = 1; $i != 16; $i++) { my $over_digit = sprintf("%x", hex($head_digit) + $i); eval { hex_natint("-".$over_digit.("0" x $tail_digits)) }; like $@, qr/\Ainteger value too large/; } 1; Data-Integer-0.007/lib/0000755000175000017500000000000014776704114012375 5ustar rrrrData-Integer-0.007/lib/Data/0000755000175000017500000000000014776704114013246 5ustar rrrrData-Integer-0.007/lib/Data/Integer.pm0000644000175000017500000010351314776701560015206 0ustar rrrr=head1 NAME Data::Integer - details of the native integer data type =head1 SYNOPSIS use Data::Integer qw(natint_bits); $n = natint_bits; # and other constants; see text use Data::Integer qw(nint sint uint nint_is_sint nint_is_uint); $ni = nint($ni); $si = sint($si); $ui = uint($ui); if(nint_is_sint($ni)) { ... if(nint_is_uint($ni)) { ... use Data::Integer qw( nint_sgn sint_sgn uint_sgn nint_abs sint_abs uint_abs nint_cmp sint_cmp uint_cmp nint_min sint_min uint_min nint_max sint_max uint_max nint_neg sint_neg uint_neg nint_add sint_add uint_add nint_sub sint_sub uint_sub); $sn = nint_sgn($ni); $sn = sint_sgn($si); $sn = uint_sgn($ui); $ni = nint_abs($ni); $si = sint_abs($si); $ui = uint_abs($ui); @sorted_nints = sort { nint_cmp($a, $b) } @nints; @sorted_sints = sort { sint_cmp($a, $b) } @sints; @sorted_uints = sort { uint_cmp($a, $b) } @uints; $ni = nint_min($na, $nb); $si = sint_min($sa, $sb); $ui = uint_min($ua, $ub); $ni = nint_max($na, $nb); $si = sint_max($sa, $sb); $ui = uint_max($ua, $ub); $ni = nint_neg($ni); $si = sint_neg($si); $ui = uint_neg($ui); $ni = nint_add($na, $nb); $si = sint_add($sa, $sb); $ui = uint_add($ua, $ub); $ni = nint_sub($na, $nb); $si = sint_sub($sa, $sb); $ui = uint_sub($ua, $ub); use Data::Integer qw( sint_shl uint_shl sint_shr uint_shr sint_rol uint_rol sint_ror uint_ror); $si = sint_shl($si, $dist); $ui = uint_shl($ui, $dist); $si = sint_shr($si, $dist); $ui = uint_shr($ui, $dist); $si = sint_rol($si, $dist); $ui = uint_rol($ui, $dist); $si = sint_ror($si, $dist); $ui = uint_ror($ui, $dist); use Data::Integer qw( nint_bits_as_sint nint_bits_as_uint sint_bits_as_uint uint_bits_as_sint); $si = nint_bits_as_sint($ni); $ui = nint_bits_as_uint($ni); $ui = sint_bits_as_uint($si); $si = uint_bits_as_sint($ui); use Data::Integer qw( sint_not uint_not sint_and uint_and sint_nand uint_nand sint_andn uint_andn sint_or uint_or sint_nor uint_nor sint_orn uint_orn sint_xor uint_xor sint_nxor uint_nxor sint_mux uint_mux); $si = sint_not($si); $ui = uint_not($ui); $si = sint_and($sa, $sb); $ui = uint_and($ua, $ub); $si = sint_nand($sa, $sb); $ui = uint_nand($ua, $ub); $si = sint_andn($sa, $sb); $ui = uint_andn($ua, $ub); $si = sint_or($sa, $sb); $ui = uint_or($ua, $ub); $si = sint_nor($sa, $sb); $ui = uint_nor($ua, $ub); $si = sint_orn($sa, $sb); $ui = uint_orn($ua, $ub); $si = sint_xor($sa, $sb); $ui = uint_xor($ua, $ub); $si = sint_nxor($sa, $sb); $ui = uint_nxor($ua, $ub); $si = sint_mux($sa, $sb, $sc); $ui = uint_mux($ua, $ub, $uc); use Data::Integer qw( sint_madd uint_madd sint_msub uint_msub sint_cadd uint_cadd sint_csub uint_csub sint_sadd uint_sadd sint_ssub uint_ssub); $si = sint_madd($sa, $sb); $ui = uint_madd($ua, $ub); $si = sint_msub($sa, $sb); $ui = uint_msub($ua, $ub); ($carry, $si) = sint_cadd($sa, $sb, $carry); ($carry, $ui) = uint_cadd($ua, $ub, $carry); ($carry, $si) = sint_csub($sa, $sb, $carry); ($carry, $ui) = uint_csub($ua, $ub, $carry); $si = sint_sadd($sa, $sb); $ui = uint_sadd($ua, $ub); $si = sint_ssub($sa, $sb); $ui = uint_ssub($ua, $ub); use Data::Integer qw(natint_hex hex_natint); print natint_hex($value); $value = hex_natint($string); =head1 DESCRIPTION This module is about the native integer numerical data type. A native integer is one of the types of datum that can appear in the numeric part of a Perl scalar. This module supplies constants describing the native integer type. There are actually two native integer representations: signed and unsigned. Both are handled by this module. =head1 NATIVE INTEGERS Each native integer format represents a value using binary place value, with some fixed number of bits. The number of bits is the same for both signed and unsigned representations. In each case the least-significant bit has the value 1, the next 2, the next 4, and so on. In the unsigned representation, this pattern continues up to and including the most-significant bit, which for a 32-bit machine therefore has the value 2^31 (2147483648). The unsigned format cannot represent any negative numbers. In the signed format, the most-significant bit is exceptional, having the negation of the value that it does in the unsigned format. Thus on a 32-bit machine this has the value -2^31 (-2147483648). Values with this bit set are negative, and those with it clear are non-negative; this bit is also known as the "sign bit". It is usual in machine arithmetic to use one of these formats at a time, for example to add two signed numbers yielding a signed result. However, Perl has a trick: a scalar with a native integer value contains an additional flag bit which indicates whether the signed or unsigned format is being used. It is therefore possible to mix signed and unsigned numbers in arithmetic, at some extra expense. =cut package Data::Integer; { use 5.006; } use warnings; use strict; use Carp qw(croak); our $VERSION = "0.007"; use parent "Exporter"; our @EXPORT_OK = qw( natint_bits min_nint max_nint min_natint max_natint min_sint max_sint min_signed_natint max_signed_natint min_uint max_uint min_unsigned_natint max_unsigned_natint nint sint uint nint_is_sint nint_is_uint nint_sgn sint_sgn uint_sgn nint_abs sint_abs uint_abs nint_cmp sint_cmp uint_cmp nint_min sint_min uint_min nint_max sint_max uint_max nint_neg sint_neg uint_neg nint_add sint_add uint_add nint_sub sint_sub uint_sub sint_shl uint_shl sint_shr uint_shr sint_rol uint_rol sint_ror uint_ror nint_bits_as_sint nint_bits_as_uint sint_bits_as_uint uint_bits_as_sint sint_not uint_not sint_and uint_and sint_nand uint_nand sint_andn uint_andn sint_or uint_or sint_nor uint_nor sint_orn uint_orn sint_xor uint_xor sint_nxor uint_nxor sint_mux uint_mux sint_madd uint_madd sint_msub uint_msub sint_cadd uint_cadd sint_csub uint_csub sint_sadd uint_sadd sint_ssub uint_ssub natint_hex hex_natint ); =head1 CONSTANTS Each of the extreme-value constants has two names, a short one and a long one. The short names are more convenient to use, but the long names are clearer in a context where other similar constants exist. Due to the risks of Perl changing the behaviour of a native integer value that has been involved in floating point arithmetic (see L), the extreme-value constants are actually non-constant functions that always return a fresh copy of the appropriate value. The returned value is always a pure native integer value, unsullied by floating point or string operations. =over =item natint_bits The width, in bits, of the native integer data types. =cut # Count the number of bits in native integers by repeatedly shifting a bit # left until it turns into the sign bit. "use integer" forces the use of a # signed integer representation. BEGIN { use integer; my $bit_count = 1; my $test_bit = 1; while($test_bit > 0) { $bit_count += 1; $test_bit <<= 1; } my $natint_bits = $bit_count; *natint_bits = sub () { $natint_bits }; } =item min_nint =item min_natint The minimum representable value in either representation. This is -2^(natint_bits - 1). =cut BEGIN { my $min_nint = do { use integer; 1 << (natint_bits - 1) }; *min_natint = *min_nint = sub() { my $ret = $min_nint }; } =item max_nint =item max_natint The maximum representable value in either representation. This is 2^natint_bits - 1. =cut BEGIN { my $max_nint = ~0; *max_natint = *max_nint = sub() { my $ret = $max_nint }; } =item min_sint =item min_signed_natint The minimum representable value in the signed representation. This is -2^(natint_bits - 1). =cut BEGIN { *min_signed_natint = *min_sint = \&min_nint; } =item max_sint =item max_signed_natint The maximum representable value in the signed representation. This is 2^(natint_bits - 1) - 1. =cut BEGIN { my $max_sint = ~min_sint; *max_signed_natint = *max_sint = sub() { my $ret = $max_sint }; } =item min_uint =item min_unsigned_natint The minimum representable value in the unsigned representation. This is zero. =cut BEGIN { my $min_uint = 0; *min_unsigned_natint = *min_uint = sub() { my $ret = $min_uint }; } =item max_uint =item max_unsigned_natint The maximum representable value in the unsigned representation. This is 2^natint_bits - 1. =cut BEGIN { *max_unsigned_natint = *max_uint = \&max_nint; } =back =head1 FUNCTIONS Each "nint_", "sint_", or "uint_" function operates on one of the three integer formats. "nint_" functions operate on Perl's union of signed and unsigned; "sint_" functions operate on signed integers; and "uint_" functions operate on unsigned integers. Except where indicated otherwise, the function returns a value of its primary type. Parameters I, I, and I, where present, must be numbers of the appropriate type: specifically, with a numerical value that can be represented in that type. If there are multiple flavours of zero, due to floating point funkiness, all zeroes are treated the same. Parameters with other names have other requirements, explained with each function. The functions attempt to detect unsuitable arguments, and C if an invalid argument is detected, but they can't notice some kinds of incorrect argument. Generally, it is the caller's responsibility to provide a sane numerical argument, and supplying an invalid argument will cause mayhem. Only the numeric value of plain scalar arguments is used; the string value is completely ignored, so dualvars are not a problem. =head2 Canonicalisation and classification These are basic glue functions. =over =item nint(A) =item sint(A) =item uint(A) These functions each take an argument in a specific integer format and return its numerical value. This is the argument canonicalisation that is performed by all of the functions in this module, presented in isolation. =cut sub nint($) { my $tval = $_[0]; croak "not a native integer" unless int($tval) == $tval && $tval >= min_nint && $tval <= max_nint; return ($tval = $_[0]) < 0 ? do { use integer; 0 | $_[0] } : 0 | $_[0]; } sub sint($) { my $tval = $_[0]; croak "not a signed native integer" unless int($tval) == $tval && $tval >= min_sint && $tval <= max_sint; my $val = do { use integer; 0 | $_[0] }; croak "not a signed native integer" if $tval >= 0 && do { use integer; $val < 0 }; return $val; } sub uint($) { my $tval = $_[0]; croak "not an unsigned native integer" unless int($tval) == $tval && $tval >= min_uint && $tval <= max_uint; return 0 | $_[0]; } =item nint_is_sint(A) Takes a native integer of either type. Returns a truth value indicating whether this value can be exactly represented as a signed native integer. =cut sub nint_is_sint($) { my $val = nint($_[0]); return (my $tval = $val) < 0 || do { use integer; ($val & min_sint) == 0 }; } =item nint_is_uint(A) Takes a native integer of either type. Returns a truth value indicating whether this value can be exactly represented as an unsigned native integer. =cut sub nint_is_uint($) { nint($_[0]) >= 0 } =back =head2 Arithmetic These functions operate on numerical values rather than just bit patterns. They will all C if the true numerical result doesn't fit into the result format, rather than give a wrong answer. =over =item nint_sgn(A) =item sint_sgn(A) =item uint_sgn(A) Returns +1 if the argument is positive, 0 if the argument is zero, or -1 if the argument is negative. =cut sub nint_sgn($) { nint($_[0]) <=> 0 } sub sint_sgn($) { use integer; sint($_[0]) <=> 0 } sub uint_sgn($) { use integer; uint($_[0]) == 0 ? 0 : +1 } =item nint_abs(A) =item sint_abs(A) =item uint_abs(A) Absolute value (magnitude, discarding sign). =cut sub nint_abs($) { my $a = nint($_[0]); if((my $tval = $a) >= 0) { return $a; } elsif(do { use integer; $a == min_sint }) { return 0 | min_sint; } else { use integer; return -$a; } } sub sint_abs($) { my $a = sint($_[0]); use integer; croak "integer overflow" if $a == min_sint; return $a < 0 ? -$a : $a; } *uint_abs = \&uint; =item nint_cmp(A, B) =item sint_cmp(A, B) =item uint_cmp(A, B) Arithmetic comparison. Returns -1, 0, or +1, indicating whether A is less than, equal to, or greater than B. =cut sub nint_cmp($$) { my($a, $b) = (nint($_[0]), nint($_[1])); if((my $ta = $a) < 0) { if((my $tb = $b) < 0) { use integer; return $a <=> $b; } else { return -1; } } else { if((my $tb = $b) < 0) { return 1; } else { use integer; return ($a ^ min_sint) <=> ($b ^ min_sint); } } } sub sint_cmp($$) { use integer; sint($_[0]) <=> sint($_[1]) } sub uint_cmp($$) { use integer; return (uint($_[0]) ^ min_sint) <=> (uint($_[1]) ^ min_sint); } =item nint_min(A, B) =item sint_min(A, B) =item uint_min(A, B) Arithmetic minimum. Returns the arithmetically lesser of the two arguments. =cut sub nint_min($$) { my($a, $b) = (nint($_[0]), nint($_[1])); if((my $ta = $a) < 0) { if((my $tb = $b) < 0) { use integer; return $a < $b ? $a : $b; } else { return $a; } } else { if((my $tb = $b) < 0) { return $b; } else { use integer; return ($a ^ min_sint) < ($b ^ min_sint) ? $a : $b; } } } sub sint_min($$) { my($a, $b) = (sint($_[0]), sint($_[1])); use integer; return $a < $b ? $a : $b; } sub uint_min($$) { my($a, $b) = (uint($_[0]), uint($_[1])); use integer; return ($a ^ min_sint) < ($b ^ min_sint) ? $a : $b; } =item nint_max(A, B) =item sint_max(A, B) =item uint_max(A, B) Arithmetic maximum. Returns the arithmetically greater of the two arguments. =cut sub nint_max($$) { my($a, $b) = (nint($_[0]), nint($_[1])); if((my $ta = $a) < 0) { if((my $tb = $b) < 0) { use integer; return $a < $b ? $b : $a; } else { return $b; } } else { if((my $tb = $b) < 0) { return $a; } else { use integer; return ($a ^ min_sint) < ($b ^ min_sint) ? $b : $a; } } } sub sint_max($$) { my($a, $b) = (sint($_[0]), sint($_[1])); use integer; return $a < $b ? $b : $a; } sub uint_max($$) { my($a, $b) = (uint($_[0]), uint($_[1])); use integer; return ($a ^ min_sint) < ($b ^ min_sint) ? $b : $a; } =item nint_neg(A) =item sint_neg(A) =item uint_neg(A) Negation: returns -A. =cut sub nint_neg($) { my $a = nint($_[0]); if((my $ta = $a) <= 0) { return 0 | do { use integer; -$a }; } else { use integer; my $neg = -$a; croak "integer overflow" if $neg >= 0; return $neg; } } sub sint_neg($) { my $a = sint($_[0]); use integer; croak "integer overflow" if $a == min_sint; return -$a; } sub uint_neg($) { use integer; croak "integer overflow" unless uint($_[0]) == 0; return my $zero = 0; } =item nint_add(A, B) =item sint_add(A, B) =item uint_add(A, B) Addition: returns A + B. =cut sub nint_add($$) { my($a, $b) = (nint($_[0]), nint($_[1])); if((my $ta = $a) < 0) { if((my $tb = $b) < 0) { use integer; my $r = $a + $b; croak "integer overflow" if $r > $a; return $r; } else { use integer; my $r = $a + $b; $r = do { no integer; 0 | $r } if $r < $a; return $r; } } else { if((my $tb = $b) < 0) { use integer; my $r = $a + $b; $r = do { no integer; 0 | $r } if $r < $b; return $r; } else { use integer; my $r = $a + $b; croak "integer overflow" if ($r ^ min_sint) < ($a ^ min_sint); return do { no integer; 0 | $r }; } } } sub sint_add($$) { my($a, $b) = (sint($_[0]), sint($_[1])); use integer; my $r = $a + $b; croak "integer overflow" if $b < 0 ? $r > $a : $r < $a; return $r; } sub uint_add($$) { my($a, $b) = (uint($_[0]), uint($_[1])); use integer; my $r = $a + $b; croak "integer overflow" if ($r ^ min_sint) < ($a ^ min_sint); return do { no integer; 0 | $r }; } =item nint_sub(A, B) =item sint_sub(A, B) =item uint_sub(A, B) Subtraction: returns A - B. =cut sub nint_sub($$) { my($a, $b) = (nint($_[0]), nint($_[1])); if((my $ta = $a) < 0) { if((my $tb = $b) < 0) { use integer; return $a - $b; } elsif(!($b & min_sint)) { use integer; my $r = $a - $b; croak "integer overflow" if $r >= 0; return $r; } else { croak "integer overflow"; } } elsif(!($a & min_sint)) { if((my $tb = $b) < 0) { return 0 | do { use integer; $a - $b }; } elsif(!($b & min_sint)) { use integer; return $a - $b; } else { use integer; my $r = $a - $b; croak "integer overflow" if $r >= 0; return $r; } } else { if((my $tb = $b) < 0) { use integer; my $r = $a - $b; croak "integer overflow" if $r >= 0; return do { no integer; 0 | $r }; } elsif(!($b & min_sint)) { return 0 | do { use integer; $a - $b }; } else { use integer; return $a - $b; } } } sub sint_sub($$) { my($a, $b) = (sint($_[0]), sint($_[1])); use integer; my $r = $a - $b; croak "integer overflow" if $b > 0 ? $r > $a : $r < $a; return $r; } sub uint_sub($$) { my($a, $b) = (uint($_[0]), uint($_[1])); use integer; my $r = $a - $b; croak "integer overflow" if ($r ^ min_sint) > ($a ^ min_sint); return do { no integer; 0 | $r }; } =back =head2 Bit shifting These functions all operate on the bit patterns representing integers, mostly ignoring the numerical values represented. In most cases the results for particular numerical arguments are influenced by the word size, because that determines where a bit being left-shifted will drop off the end of the word and where a bit will be shifted in during a rightward shift. With the exception of rightward shifts (see below), each pair of functions performs exactly the same operations on the bit sequences. There inevitably can't be any functions here that operate on Perl's union of signed and unsigned; you must choose, by which function you call, which type the result is to be tagged as. =over =item sint_shl(A, DIST) =item uint_shl(A, DIST) Bitwise left shift (towards more-significant bits). I is the distance to shift, in bits, and must be an integer in the range [0, natint_bits). Zeroes are shifted in from the right. =cut sub sint_shl($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; use integer; return sint($val) << $dist; } sub uint_shl($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; no integer; return uint($val) << $dist; } =item sint_shr(A, DIST) =item uint_shr(A, DIST) Bitwise right shift (towards less-significant bits). I is the distance to shift, in bits, and must be an integer in the range [0, natint_bits). When performing an unsigned right shift, zeroes are shifted in from the left. A signed right shift is different: the sign bit gets duplicated, so right-shifting a negative number always gives a negative result. =cut sub sint_shr($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; use integer; return sint($val) >> $dist; } sub uint_shr($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; no integer; return uint($val) >> $dist; } =item sint_rol(A, DIST) =item uint_rol(A, DIST) Bitwise left rotation (towards more-significant bits, with the most-significant bit wrapping round to the least-significant bit). I is the distance to rotate, in bits, and must be an integer in the range [0, natint_bits). =cut sub sint_rol($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; $val = sint($val); return $val if $dist == 0; my $low_val = $val >> (natint_bits - $dist); use integer; return $low_val | ($val << $dist); } sub uint_rol($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; $val = uint($val); return $val if $dist == 0; return ($val >> (natint_bits - $dist)) | ($val << $dist); } =item sint_ror(A, DIST) =item uint_ror(A, DIST) Bitwise right rotation (towards less-significant bits, with the least-significant bit wrapping round to the most-significant bit). I is the distance to rotate, in bits, and must be an integer in the range [0, natint_bits). =cut sub sint_ror($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; $val = sint($val); return $val if $dist == 0; my $low_val = $val >> $dist; use integer; return $low_val | ($val << (natint_bits - $dist)); } sub uint_ror($$) { my($val, $dist) = @_; $dist = uint($dist); croak "shift distance exceeds word size" if $dist >= natint_bits; $val = uint($val); return $val if $dist == 0; return ($val >> $dist) | ($val << (natint_bits - $dist)); } =back =head2 Format conversion These functions convert between the various native integer formats by reinterpreting the bit patterns used to represent the integers. The bit pattern remains unchanged; its meaning changes, and so the numerical value changes. Perl scalars preserve the numerical value, rather than just the bit pattern, so from the Perl point of view these are functions that change numbers into other numbers. =over =item nint_bits_as_sint(A) Converts a native integer of either type to a signed integer, by reinterpreting the bits. The most-significant bit (whether a sign bit or not) becomes a sign bit. =cut sub nint_bits_as_sint($) { use integer; nint($_[0]) | 0 } =item nint_bits_as_uint(A) Converts a native integer of either type to an unsigned integer, by reinterpreting the bits. The most-significant bit (whether a sign bit or not) becomes an ordinary most-significant bit. =cut sub nint_bits_as_uint($) { no integer; nint($_[0]) | 0 } =item sint_bits_as_uint(A) Converts a signed integer to an unsigned integer, by reinterpreting the bits. The sign bit becomes an ordinary most-significant bit. =cut sub sint_bits_as_uint($) { no integer; sint($_[0]) | 0 } =item uint_bits_as_sint(A) Converts an unsigned integer to a signed integer, by reinterpreting the bits. The most-significant bit becomes a sign bit. =cut sub uint_bits_as_sint($) { use integer; uint($_[0]) | 0 } =back =head2 Bitwise operations These functions all operate on the bit patterns representing integers, completely ignoring the numerical values represented. They are mostly not influenced by the word size, in the sense that they will produce the same numerical result for the same numerical arguments regardless of word size. However, a few are affected by the word size: those on unsigned operands that return a non-zero result if given zero arguments. Each pair of functions performs exactly the same operations on the bit sequences. There inevitably can't be any functions here that operate on Perl's union of signed and unsigned; you must choose, by which function you call, which type the result is to be tagged as. =over =item sint_not(A) =item uint_not(A) Bitwise complement (NOT). =cut sub sint_not($) { use integer; ~sint($_[0]) } sub uint_not($) { no integer; ~uint($_[0]) } =item sint_and(A, B) =item uint_and(A, B) Bitwise conjunction (AND). =cut sub sint_and($$) { use integer; sint($_[0]) & sint($_[1]) } sub uint_and($$) { no integer; uint($_[0]) & uint($_[1]) } =item sint_nand(A, B) =item uint_nand(A, B) Bitwise inverted conjunction (NAND). =cut sub sint_nand($$) { use integer; ~(sint($_[0]) & sint($_[1])) } sub uint_nand($$) { no integer; ~(uint($_[0]) & uint($_[1])) } =item sint_andn(A, B) =item uint_andn(A, B) Bitwise conjunction with inverted argument (A AND (NOT B)). =cut sub sint_andn($$) { use integer; sint($_[0]) & ~sint($_[1]) } sub uint_andn($$) { no integer; uint($_[0]) & ~uint($_[1]) } =item sint_or(A, B) =item uint_or(A, B) Bitwise disjunction (OR). =cut sub sint_or($$) { use integer; sint($_[0]) | sint($_[1]) } sub uint_or($$) { no integer; uint($_[0]) | uint($_[1]) } =item sint_nor(A, B) =item uint_nor(A, B) Bitwise inverted disjunction (NOR). =cut sub sint_nor($$) { use integer; ~(sint($_[0]) | sint($_[1])) } sub uint_nor($$) { no integer; ~(uint($_[0]) | uint($_[1])) } =item sint_orn(A, B) =item uint_orn(A, B) Bitwise disjunction with inverted argument (A OR (NOT B)). =cut sub sint_orn($$) { use integer; sint($_[0]) | ~sint($_[1]) } sub uint_orn($$) { no integer; uint($_[0]) | ~uint($_[1]) } =item sint_xor(A, B) =item uint_xor(A, B) Bitwise symmetric difference (XOR). =cut sub sint_xor($$) { use integer; sint($_[0]) ^ sint($_[1]) } sub uint_xor($$) { no integer; uint($_[0]) ^ uint($_[1]) } =item sint_nxor(A, B) =item uint_nxor(A, B) Bitwise symmetric similarity (NXOR). =cut sub sint_nxor($$) { use integer; ~(sint($_[0]) ^ sint($_[1])) } sub uint_nxor($$) { no integer; ~(uint($_[0]) ^ uint($_[1])) } =item sint_mux(A, B, C) =item uint_mux(A, B, C) Bitwise multiplex. The output has a bit from B wherever A has a 1 bit, and a bit from C wherever A has a 0 bit. That is, the result is (A AND B) OR ((NOT A) AND C). =cut sub sint_mux($$$) { my $a = sint($_[0]); use integer; return ($a & sint($_[1])) | (~$a & sint($_[2])); } sub uint_mux($$$) { my $a = uint($_[0]); no integer; return ($a & uint($_[1])) | (~$a & uint($_[2])); } =back =head2 Machine arithmetic These functions perform arithmetic operations that are inherently influenced by the word size. They always produce a well-defined output if given valid inputs. There inevitably can't be any functions here that operate on Perl's union of signed and unsigned; you must choose, by which function you call, which type the result is to be tagged as. =over =item sint_madd(A, B) =item uint_madd(A, B) Modular addition. The result for unsigned addition is (A + B) mod 2^natint_bits. The signed version behaves similarly, but with a different result range. =cut sub sint_madd($$) { use integer; sint($_[0]) + sint($_[1]) } sub uint_madd($$) { 0 | do { use integer; uint($_[0]) + uint($_[1]) } } =item sint_msub(A, B) =item uint_msub(A, B) Modular subtraction. The result for unsigned subtraction is (A - B) mod 2^natint_bits. The signed version behaves similarly, but with a different result range. =cut sub sint_msub($$) { use integer; sint($_[0]) - sint($_[1]) } sub uint_msub($$) { 0 | do { use integer; uint($_[0]) - uint($_[1]) } } =item sint_cadd(A, B, CARRY_IN) =item uint_cadd(A, B, CARRY_IN) Addition with carry. Two word arguments (A and B) and an input carry bit (CARRY_IN, which must have the value 0 or 1) are all added together. Returns a list of two items: an output carry and an output word (of the same signedness as the inputs). Precisely, the output list (CARRY_OUT, R) is such that CARRY_OUT*2^natint_bits + R = A + B + CARRY_IN. =cut sub sint_cadd($$$) { my($a, $b, $cin) = map { sint($_) } @_; use integer; croak "invalid carry" unless $cin == 0 || $cin == 1; my $r = $a + $b + $cin; my $cout = $b < 0 ? $r > $a ? -1 : 0 : $r < $a ? +1 : 0; return ($cout, $r); } sub uint_cadd($$$) { my($a, $b, $cin) = map { uint($_) } @_; use integer; croak "invalid carry" unless $cin == 0 || $cin == 1; my $r = $a + $b; my $cout = ($r ^ min_sint) < ($a ^ min_sint) ? 1 : 0; if($cin) { $r += 1; $cout = 1 if $r == 0; } return ($cout, do { no integer; 0 | $r }); } =item sint_csub(A, B, CARRY_IN) =item uint_csub(A, B, CARRY_IN) Subtraction with carry (borrow). The second word argument (B) and an input carry bit (CARRY_IN, which must have the value 0 or 1) are subtracted from the first word argument (A). Returns a list of two items: an output carry and an output word (of the same signedness as the inputs). Precisely, the output list (CARRY_OUT, R) is such that R - CARRY_OUT*2^natint_bits = A - B - CARRY_IN. =cut sub sint_csub($$$) { my($a, $b, $cin) = map { sint($_) } @_; use integer; croak "invalid carry" unless $cin == 0 || $cin == 1; my $r = $a - $b - $cin; my $cout = $b < 0 ? $r < $a ? -1 : 0 : $r > $a ? +1 : 0; return ($cout, $r); } sub uint_csub($$$) { my($a, $b, $cin) = map { uint($_) } @_; use integer; croak "invalid carry" unless $cin == 0 || $cin == 1; my $r = $a - $b; my $cout = ($r ^ min_sint) > ($a ^ min_sint) ? 1 : 0; if($cin) { $cout = 1 if $r == 0; $r -= 1; } return ($cout, do { no integer; 0 | $r }); } =item sint_sadd(A, B) =item uint_sadd(A, B) Saturating addition. The result is A + B if that will fit into the result format, otherwise the minimum or maximum value of the result format is returned depending on the direction in which the addition overflowed. =cut sub sint_sadd($$) { my($a, $b) = map { sint($_) } @_; use integer; my $r = $a + $b; if($b < 0) { $r = min_sint if $r > $a; } else { $r = max_sint if $r < $a; } return $r; } sub uint_sadd($$) { my($a, $b) = map { uint($_) } @_; use integer; my $r = $a + $b; $r = max_uint if ($r ^ min_sint) < ($a ^ min_sint); return do { no integer; 0 | $r }; } =item sint_ssub(A, B) =item uint_ssub(A, B) Saturating subtraction. The result is A - B if that will fit into the result format, otherwise the minimum or maximum value of the result format is returned depending on the direction in which the subtraction overflowed. =cut sub sint_ssub($$) { my($a, $b) = map { sint($_) } @_; use integer; my $r = $a - $b; if($b >= 0) { $r = min_sint if $r > $a; } else { $r = max_sint if $r < $a; } return $r; } sub uint_ssub($$) { my($a, $b) = map { uint($_) } @_; use integer; my $r = ($a ^ min_sint) <= ($b ^ min_sint) ? 0 : $a - $b; return do { no integer; 0 | $r }; } =back =head2 String conversion =over =item natint_hex(VALUE) VALUE must be a native integer value. The function encodes VALUE in hexadecimal, returning that representation as a string. Specifically, the output is of the form "IB<0x>I", where "I" is the sign and "I" is a sequence of hexadecimal digits. =cut sub natint_hex($) { my $val = nint($_[0]); my $sgn = nint_sgn($val); $val = nint_abs($val); my $digits = ""; my $i = (natint_bits+3) >> 2; for(; $i >= 7; $i -= 7) { $digits = sprintf("%07x", $val & 0xfffffff).$digits; $val >>= 28; } for(; $i--; ) { $digits = sprintf("%01x", $val & 0xf).$digits; $val >>= 4; } return ($sgn == -1 ? "-" : "+")."0x".$digits; } =item hex_natint(STRING) Generates and returns a native integer value from a string encoding it in hexadecimal. Specifically, the input format is "[I][B<0x>]I", where "I" is the sign and "I" is a sequence of one or more hexadecimal digits. The input is interpreted case insensitively. If the value given in the string cannot be exactly represented in the native integer type, the function Cs. The core Perl function C (see L) does a similar job to this function, but differs in several ways. Principally, C doesn't handle negative values, and it gives the wrong answer for values that don't fit into the native integer type. In Perl 5.6 it also gives the wrong answer for values that don't fit into the native floating point type. It also doesn't enforce strict syntax on the input string. =cut my %hexdigit_value; { use integer; $hexdigit_value{chr(ord("0") + $_)} = $_ foreach 0..9; $hexdigit_value{chr(ord("a") + $_)} = 10+$_ foreach 0..5; $hexdigit_value{chr(ord("A") + $_)} = 10+$_ foreach 0..5; } sub hex_natint($) { my($str) = @_; $str =~ /\A([-+]?)(?:0x)?([0-9a-f]+)\z/i or croak "bad syntax for hexadecimal integer value"; my($sign, $digits) = ($1, $2); use integer; $digits =~ /\A0*/g; return my $zero = 0 if $digits =~ /\G\z/gc; $digits =~ /\G(.)/g; my $value = $hexdigit_value{$1}; my $bits_to_go = (length($digits)-pos($digits)) << 2; croak "integer value too large" if $bits_to_go >= natint_bits || ($bits_to_go + 4 > natint_bits && (max_uint >> $bits_to_go) < $value); while($digits =~ /\G(.)/g) { $value = ($value << 4) | $hexdigit_value{$1}; } if($sign eq "-") { $value = -$value; croak "integer value too large" if $value >= 0; return $value; } else { no integer; return 0 | $value; } } =back =head1 BUGS In Perl 5.6, when a native integer scalar is used in any arithmetic other than specifically integer arithmetic, it gets partially transformed into a floating point scalar. Even if its numerical value can be represented exactly in floating point, so that floating point arithmetic uses the correct numerical value, some operations are affected by the floatness. In particular, the stringification of the scalar doesn't necessarily represent its exact value if it is tagged as floating point. Because of this transforming behaviour, if you need to stringify a native integer it is best to ensure that it doesn't get used in any non-integer arithmetic first. If an integer scalar must be used in standard Perl arithmetic, it may be copied first and the copy operated upon to avoid causing side effects on the original. If an integer scalar might have already been transformed, it can be cleaned by passing it through the canonicalisation function C. The functions in this module all avoid modifying their arguments, and always return pristine integers. Perl 5.8+ still internally modifies integer scalars in the same circumstances, but seems to have corrected all the misbehaviour that resulted from it. Also in Perl 5.6, default Perl arithmetic doesn't necessarily work correctly on native integers. (This is part of the motivation for the myriad arithmetic functions in this module.) Default arithmetic here is strictly floating point, so if there are native integers that cannot be exactly represented in floating point then the arithmetic will approximate the values before operating on them. Perl 5.8+ attempts to use native integer operations where possible in its default arithmetic, but as of Perl 5.8.8 it doesn't always succeed. For reliable integer arithmetic, integer operations must still be requested explicitly. =head1 SEE ALSO L, L, L =head1 AUTHOR Andrew Main (Zefram) Currently maintained by Robert Rothenberg =head1 COPYRIGHT Copyright (C) 2007, 2010, 2015, 2017, 2025 Andrew Main (Zefram) =head1 LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =cut 1; Data-Integer-0.007/MANIFEST.SKIP0000644000175000017500000000012714776703677013542 0ustar rrrrData-Integer-* Makefile$ MYMETA pm_to_blib blib/ .git/ _build/ MANIFEST.bak .gitignore Data-Integer-0.007/Changes0000644000175000017500000000715714776704055013140 0ustar rrrrRevision history for Data-Integer: 0.007 2025-04-13 10:47 Europe/London [Documentation] - Updated maintainer information. - Reformatted Changes to conform to CPAN::Changes::Spec. - Added a security policy. [Toolchain] - Switched to use Makefile.PL. - Cleaned up MANIFEST. 0.006 2017-08-07 - no longer include a Makefile.PL in the distribution - in documentation, use four-column indentation for all verbatim material - in META.{yml,json}, point to public bug tracker 0.005 2015-03-29 - avoid a spurious warning generated by new Perls starting with Perl 5.21.6 - include META.json in distribution - convert .cvsignore to .gitignore - add MYMETA.json to .cvsignore 0.004 2010-07-26 - in documentation of {s,u}int_msub(), correct description that said "addition" instead of "subtraction" - in synopsis, correct number of parameters for {s,u}int_mux() - use simpler "parent" pragma in place of "base" - in documentation, use the term "truth value" instead of the less precise "boolean" - check for required Perl version at runtime - use full stricture in test suite - use full stricture in Build.PL - in Build.PL, explicitly declare configure-time requirements - remove bogus "exit 0" from Build.PL - add MYMETA.yml to .cvsignore 0.003 2007-10-26 - add natint_hex() and hex_natint() functions to output and input integer values in hexadecimal - add functions {n,s,u}int() to check and canonicalise native integer function arguments - add functions nint_is_{s,u}int() for classification of native integers - add functions {n,s,u}int_sgn(), {n,s,u}int_abs(), {n,s,u}int_cmp(), {n,s,u}int_min(), {n,s,u}int_max(), {n,s,u}int_neg(), {n,s,u}int_add(), {n,s,u}int_sub() for ordinary arithmetic on native integers - add functions {s,u}int_shl(), {s,u}int_shr(), {s,u}int_rol(), {s,u}int_ror() for bit shifts on native integers - add functions {n,u}int_bits_as_sint() and {n,s}int_bits_as_uint() for format conversions among native integers - add functions {s,u}int_not(), {s,u}int_and(), {s,u}int_nand(), {s,u}int_andn(), {s,u}int_or(), {s,u}int_nor(), {s,u}int_orn(), {s,u}int_xor(), {s,u}int_nxor(), {s,u}int_mux() for bitwise operations on native integers - add functions {s,u}int_madd(), {s,u}int_msub(), {s,u}int_cadd(), {s,u}int_csub(), {s,u}int_sadd(), {s,u}int_ssub() for machine-code style arithmetic on native integers - add short names (m{in,ax}_{n,s,u}int) for the extreme-value constants - revise the way the constants are generated to avoid floating point arithmetic - make extreme-value constants into non-constant functions that return fresh integer values, to avoid problems with Perl's side effects when an integer value is used in floating point arithmetic - in documentation, discuss Perl's problems in handling native integer values - in documentation, describe the integer formats - test consistency of constants in a more reliable and stringent manner, using primarily integer arithmetic - rearrange module source to avoid the need for the DATA filehandle 0.002 2007-09-27 - test POD syntax and coverage - build with Module::Build instead of ExtUtils::MakeMaker - complete dependency list - include signature in distribution - in documentation, separate "license" section from "copyright" section 0.001 2007-01-24 - bugfix: strategic use of "use integer" to make the arithmetic work right on perl 5.6 - reference Data::Float, Scalar::Number, and perlnumber(1) in documentation 0.000 2007-01-09 - initial released version Data-Integer-0.007/README0000644000175000017500000000144014776701721012507 0ustar rrrrNAME Data::Integer - details of the native integer data type DESCRIPTION This module is about the native integer numerical data type. A native integer is one of the types of datum that can appear in the numeric part of a Perl scalar. This module supplies constants describing the native integer type. There are actually two native integer representations: signed and unsigned. Both are handled by this module. INSTALLATION perl Makefile.PL make make test make install AUTHOR Andrew Main (Zefram) Currently maintained by Robert Rothenberg COPYRIGHT Copyright (C) 2007, 2010, 2015, 2017, 2025 Andrew Main (Zefram) LICENSE This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. Data-Integer-0.007/SECURITY.md0000644000175000017500000000735514776703314013433 0ustar rrrr# Security Policy for the Data-Integer distribution. Security vulnerabilities can be reported via the project GitHub repository [Security Advisories](https://github.com/robrwo/Data-Integer/security/advisories). This is the Security Policy for Data-Integer. This text is based on the CPAN Security Group's Guidelines for Adding a Security Policy to Perl Distributions (version 1.2.0) https://security.metacpan.org/docs/guides/security-policy-for-authors.html # How to Report a Security Vulnerability Security vulnerabilities can be reported via the project GitHub repository [Security Advisories](https://github.com/robrwo/Data-Integer/security/advisories). Please include as many details as possible, including code samples or test cases, so that we can reproduce the issue. Check that your report does not expose any sensitive data, such as passwords, tokens, or personal information. If you would like any help with triaging the issue, or if the issue is being actively exploited, please copy the report to the CPAN Security Group (CPANSec) at . Please *do not* use the public issue reporting system on RT or GitHub issues for reporting security vulnerabilities. Please do not disclose the security vulnerability in public forums until past any proposed date for public disclosure, or it has been made public by the maintainers or CPANSec. That includes patches or pull requests. For more information, see [Report a Security Issue](https://security.metacpan.org/docs/report.html) on the CPANSec website. ## Response to Reports The maintainer(s) aim to acknowledge your security report as soon as possible. However, this project is maintained by a single person in their spare time, and they cannot guarantee a rapid response. If you have not received a response from them within one week, then please send a reminder to them and copy the report to CPANSec at . Please note that the initial response to your report will be an acknowledgement, with a possible query for more information. It will not necessarily include any fixes for the issue. The project maintainer(s) may forward this issue to the security contacts for other projects where we believe it is relevant. This may include embedded libraries, system libraries, prerequisite modules or downstream software that uses this software. They may also forward this issue to CPANSec. # Which Software This Policy Applies To Any security vulnerabilities in Data-Integer are covered by this policy. Security vulnerabilities are considered anything that allows users to execute unauthorised code, access unauthorised resources, or to have an adverse impact on accessibility or performance of a system. Security vulnerabilities in upstream software (embedded libraries, prerequisite modules or system libraries, or in Perl), are not covered by this policy unless they affect Data-Integer, or Data-Integer can be used to exploit vulnerabilities in them. Security vulnerabilities in downstream software (any software that uses Data-Integer, or plugins to it that are not included with the Data-Integer distribution) are not covered by this policy. ## Supported Versions of Data-Integer The maintainer(s) will only commit to releasing security fixes for the latest version of Data-Integer. # Installation and Usage Issues The distribution metadata specifies minimum versions of prerequisites that are required for Data-Integer to work. However, some of these prerequisites may have security vulnerabilities, and you should ensure that you are using up-to-date versions of these prerequisites. Where security vulnerabilities are known, the metadata may indicate newer versions as recommended. ## Usage Please see the software documentation for further information. Data-Integer-0.007/META.yml0000664000175000017500000000147714776704114013113 0ustar rrrr--- abstract: 'details of the native integer data type' author: - 'Robert Rothenberg ' build_requires: ExtUtils::MakeMaker: '0' Test::More: '0' configure_requires: ExtUtils::MakeMaker: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.74, CPAN::Meta::Converter version 2.150010' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Data-Integer no_index: directory: - t - inc requires: Carp: '0' Exporter: '0' constant: '0' integer: '0' parent: '0' perl: '5.006' strict: '0' warnings: '0' resources: bugtracker: https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Integer repository: git://github.com/robrwo/Data-Integer.git version: '0.007' x_serialization_backend: 'CPAN::Meta::YAML version 0.020' Data-Integer-0.007/Makefile.PL0000644000175000017500000000160714776702267013614 0ustar rrrr require 5.006; use ExtUtils::MakeMaker; WriteMakefile( 'NAME' => 'Data::Integer', 'AUTHOR' => 'Robert Rothenberg ', 'ABSTRACT_FROM' => 'lib/Data/Integer.pm', 'VERSION_FROM' => 'lib/Data/Integer.pm', "LICENSE" => "perl", 'PREREQ_PM' => { "Carp" => 0, "Exporter" => 0, "constant" => 0, "integer" => 0, "parent" => 0, "perl" => "5.006", 'strict' => 0, 'warnings' => 0, }, TEST_REQUIRES => { 'Test::More' => 0, }, 'INSTALLDIRS' => 'site', 'EXE_FILES' => [], 'PL_FILES' => {}, 'SIGN' => 1, 'META_MERGE' => { resources => { repository => 'git://github.com/robrwo/Data-Integer.git', bugtracker => 'https://rt.cpan.org/Public/Dist/Display.html?Name=Data-Integer', }, } );