From: Nicholas Clark Date: Sun, 7 Jan 2001 21:07:18 +0000 (+0000) Subject: [ID 20010107.012] [PATCH] 18446744073709551616e0 was treated as UV=18446744073709551615 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=09bb3e277be365399d3c135a30bd01910fe25c56;p=p5sagit%2Fp5-mst-13.2.git [ID 20010107.012] [PATCH] 18446744073709551616e0 was treated as UV=18446744073709551615 Message-Id: <20010107210717.D1048@plum.flirble.org> p4raw-id: //depot/perl@8366 --- diff --git a/sv.c b/sv.c index c4935d8..0da17e1 100644 --- a/sv.c +++ b/sv.c @@ -1678,6 +1678,12 @@ S_sv_2iuv_non_preserve (pTHX_ register SV *sv, I32 numtype) SvIsUV_on(sv); SvUVX(sv) = U_V(SvNVX(sv)); if ((NV)(SvUVX(sv)) == SvNVX(sv)) { + if (SvUVX(sv) == UV_MAX) { + /* As we know that NVs don't preserve UVs, UV_MAX cannot + possibly be preserved by NV. Hence, it must be overflow. + NOK, IOKp */ + return IS_NUMBER_OVERFLOW_UV; + } SvIOK_on(sv); /* Integer is precise. NOK, UOK */ } else { /* Integer is imprecise. NOK, IOKp */ diff --git a/t/op/64bitint.t b/t/op/64bitint.t index 47779dd..c34d188 100644 --- a/t/op/64bitint.t +++ b/t/op/64bitint.t @@ -16,7 +16,7 @@ BEGIN { # 32+ bit integers don't cause noise no warnings qw(overflow portable); -print "1..57\n"; +print "1..58\n"; my $q = 12345678901; my $r = 23456789012; @@ -320,4 +320,10 @@ if ($num eq $string) { print "not ok 57 # \"$num\" ne \"$string\"\n"; } +$q = "18446744073709551616e0"; +$q += 0; +print "# \"18446744073709551616e0\" += 0 gives $q\nnot " if "$q" eq "18446744073709551615"; +print "ok 58\n"; + + # eof