r6433 - in /branches/upstream/libdata-integer-perl: ./ current/ current/.cvsignore current/Changes current/MANIFEST current/META.yml current/Makefile.PL current/README current/lib/ current/lib/Data/ current/lib/Data/Integer.pm current/t/ current/t/const.t
gregoa-guest at users.alioth.debian.org
gregoa-guest at users.alioth.debian.org
Fri Aug 10 13:23:51 UTC 2007
Author: gregoa-guest
Date: Fri Aug 10 13:23:51 2007
New Revision: 6433
URL: http://svn.debian.org/wsvn/?sc=1&rev=6433
Log:
[svn-inject] Installing original source of libdata-integer-perl
Added:
branches/upstream/libdata-integer-perl/
branches/upstream/libdata-integer-perl/current/
branches/upstream/libdata-integer-perl/current/.cvsignore
branches/upstream/libdata-integer-perl/current/Changes
branches/upstream/libdata-integer-perl/current/MANIFEST
branches/upstream/libdata-integer-perl/current/META.yml
branches/upstream/libdata-integer-perl/current/Makefile.PL
branches/upstream/libdata-integer-perl/current/README
branches/upstream/libdata-integer-perl/current/lib/
branches/upstream/libdata-integer-perl/current/lib/Data/
branches/upstream/libdata-integer-perl/current/lib/Data/Integer.pm
branches/upstream/libdata-integer-perl/current/t/
branches/upstream/libdata-integer-perl/current/t/const.t
Added: branches/upstream/libdata-integer-perl/current/.cvsignore
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/.cvsignore?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/.cvsignore (added)
+++ branches/upstream/libdata-integer-perl/current/.cvsignore Fri Aug 10 13:23:51 2007
@@ -1,0 +1,4 @@
+Makefile Makefile.old
+blib pm_to_blib
+META.yml
+Data-Integer-*
Added: branches/upstream/libdata-integer-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/Changes?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/Changes (added)
+++ branches/upstream/libdata-integer-perl/current/Changes Fri Aug 10 13:23:51 2007
@@ -1,0 +1,11 @@
+version 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
+
+version 0.000; 2007-01-09
+
+ * initial released version
Added: branches/upstream/libdata-integer-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/MANIFEST?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/MANIFEST (added)
+++ branches/upstream/libdata-integer-perl/current/MANIFEST Fri Aug 10 13:23:51 2007
@@ -1,0 +1,8 @@
+.cvsignore
+Changes
+MANIFEST
+META.yml
+Makefile.PL
+README
+lib/Data/Integer.pm
+t/const.t
Added: branches/upstream/libdata-integer-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/META.yml?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/META.yml (added)
+++ branches/upstream/libdata-integer-perl/current/META.yml Fri Aug 10 13:23:51 2007
@@ -1,0 +1,10 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: Data-Integer
+version: 0.001
+version_from: lib/Data/Integer.pm
+installdirs: site
+requires:
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.17
Added: branches/upstream/libdata-integer-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/Makefile.PL?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/Makefile.PL (added)
+++ branches/upstream/libdata-integer-perl/current/Makefile.PL Fri Aug 10 13:23:51 2007
@@ -1,0 +1,7 @@
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+ NAME => "Data::Integer",
+ VERSION_FROM => "lib/Data/Integer.pm",
+ PREREQ_PM => { },
+);
Added: branches/upstream/libdata-integer-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/README?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/README (added)
+++ branches/upstream/libdata-integer-perl/current/README Fri Aug 10 13:23:51 2007
@@ -1,0 +1,31 @@
+NAME
+
+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) <zefram at fysh.org>
+
+COPYRIGHT
+
+Copyright (C) 2007 Andrew Main (Zefram) <zefram at fysh.org>
+
+This module is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
Added: branches/upstream/libdata-integer-perl/current/lib/Data/Integer.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/lib/Data/Integer.pm?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/lib/Data/Integer.pm (added)
+++ branches/upstream/libdata-integer-perl/current/lib/Data/Integer.pm Fri Aug 10 13:23:51 2007
@@ -1,0 +1,126 @@
+=head1 NAME
+
+Data::Integer - details of the native integer data type
+
+=head1 SYNOPSIS
+
+ use Data::Integer qw(max_natint);
+
+ $n = max_natint;
+
+ # and other constants; see text
+
+=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.
+
+=cut
+
+package Data::Integer;
+
+use warnings;
+use strict;
+
+our $VERSION = "0.001";
+
+use base "Exporter";
+our @EXPORT_OK = qw(
+ natint_bits min_natint max_natint
+ min_signed_natint max_signed_natint
+ min_unsigned_natint max_unsigned_natint
+);
+
+=head1 CONSTANTS
+
+=over
+
+=item natint_bits
+
+The width, in bits, of the native integer data type.
+
+=item min_natint
+
+The minimum representable value. This is -2^(natint_bits - 1).
+
+=item max_natint
+
+The maximum representable value. This is 2^natint_bits - 1.
+
+=item min_signed_natint
+
+The minimum representable value in the signed representation. This is
+-2^(natint_bits - 1).
+
+=item max_signed_natint
+
+The maximum representable value in the signed representation. This is
+2^(natint_bits - 1) - 1.
+
+=item min_unsigned_natint
+
+The minimum representable value in the unsigned representation.
+This is zero.
+
+=item max_unsigned_natint
+
+The maximum representable value in the unsigned representation. This is
+2^natint_bits - 1.
+
+=back
+
+=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.
+{
+ use integer;
+ my $natint_bits = 1;
+ my $min_signed_natint = 1;
+ while($min_signed_natint > 0) {
+ $natint_bits++;
+ $min_signed_natint <<= 1;
+ }
+ *natint_bits = sub () { $natint_bits };
+ *min_signed_natint = sub () { $min_signed_natint };
+}
+
+# The rest of the code is parsed after the constants above have been
+# calculated and installed, so that it can benefit from their constancy.
+eval do { local $/; <DATA>; } or die $@;
+__DATA__
+local $SIG{__DIE__};
+
+use constant max_signed_natint => do { use integer; ~min_signed_natint };
+use constant min_unsigned_natint => 0;
+use constant max_unsigned_natint => max_signed_natint + max_signed_natint + 1;
+
+*min_natint = \&min_signed_natint;
+*max_natint = \&max_unsigned_natint;
+
+=head1 SEE ALSO
+
+L<Data::Float>,
+L<Scalar::Number>,
+L<perlnumber(1)>
+
+=head1 AUTHOR
+
+Andrew Main (Zefram) <zefram at fysh.org>
+
+=head1 COPYRIGHT
+
+Copyright (C) 2007 Andrew Main (Zefram) <zefram at fysh.org>
+
+This module is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+=cut
+
+1;
Added: branches/upstream/libdata-integer-perl/current/t/const.t
URL: http://svn.debian.org/wsvn/branches/upstream/libdata-integer-perl/current/t/const.t?rev=6433&op=file
==============================================================================
--- branches/upstream/libdata-integer-perl/current/t/const.t (added)
+++ branches/upstream/libdata-integer-perl/current/t/const.t Fri Aug 10 13:23:51 2007
@@ -1,0 +1,30 @@
+use Test::More tests => 10;
+
+BEGIN { use_ok "Data::Integer", qw(
+ natint_bits min_natint max_natint
+ min_signed_natint max_signed_natint
+ min_unsigned_natint max_unsigned_natint
+); }
+
+ok int(natint_bits) == natint_bits;
+ok natint_bits >= 16;
+
+use integer;
+
+my $a = -1;
+for(my $i = natint_bits-1; $i--; ) { $a += $a; }
+is $a, min_signed_natint;
+is $a, min_natint;
+
+is min_signed_natint + max_signed_natint, -1;
+
+no integer;
+
+is min_unsigned_natint, 0;
+
+my $b = 1;
+my $c = 1;
+for(my $i = natint_bits-1; $i--; ) { $b += $b; $c += $b; }
+is $b - 1, max_signed_natint;
+is $c, max_unsigned_natint;
+is $c, max_natint;
More information about the Pkg-perl-cvs-commits
mailing list