This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
numeric.c:S_mulexp10 -- quit when you can
[perl5.git] / t / op / numconvert.t
index d41594e..fedef70 100755 (executable)
@@ -48,9 +48,11 @@ my $max_chain = $ENV{PERL_TEST_NUMCONVERTS} || 2;
 my $max_uv1 = ~0;
 my $max_uv2 = sprintf "%u", $max_uv1 ** 6; # 6 is an arbitrary number here
 my $big_iv = do {use integer; $max_uv1 * 16}; # 16 is an arbitrary number here
+my $max_uv_less3 = $max_uv1 - 3;
 
 print "# max_uv1 = $max_uv1, max_uv2 = $max_uv2, big_iv = $big_iv\n";
-if ($max_uv1 ne $max_uv2 or $big_iv > $max_uv1) {
+print "# max_uv_less3 = $max_uv_less3\n";
+if ($max_uv1 ne $max_uv2 or $big_iv > $max_uv1 or $max_uv1 == $max_uv_less3) {
   print "1..0 # skipped: unsigned perl arithmetic is not sane";
   eval { require Config; import Config };
   use vars qw(%Config);
@@ -60,6 +62,10 @@ if ($max_uv1 ne $max_uv2 or $big_iv > $max_uv1) {
   print "\n";
   exit 0;
 }
+if ($max_uv_less3 =~ tr/0-9//c) {
+  print "1..0 # skipped: this perl stringifies large unsigned integers using E notation\n";
+  exit 0;
+}
 
 my $st_t = 4*4;                        # We try 4 initializers and 4 reporters
 
@@ -224,9 +230,15 @@ for my $num_chain (1..$max_chain) {
                     and $ans[0] == $ans[1] and $ans[0] <= ~0
                      # First must be in E notation (ie not just digits) and
                      # second must still be an integer.
+                    # eg 1.84467440737095516e+19
+                    # 1.84467440737095516e+19 for 64 bit mantissa is in the
+                    # integer range, so 1.84467440737095516e+19 + 0 is treated
+                    # as integer addition. [should it be?]
+                    # and 18446744073709551600 + 0 is 18446744073709551600
+                    # Which isn't the string you first thought of.
                      # I can't remember why there isn't symmetry in this
                      # exception, ie why only the first ops are tested for 'N'
-                     and $ans[0] !~ /^-?\d+$/ and $ans[0] !~ /^-?\d+$/) {
+                     and $ans[0] != /^-?\d+$/ and $ans[1] !~ /^-?\d+$/) {
              print "# ok, numerically equal - notation changed due to adding zero\n";
            } else {
              $nok++,