summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2008-01-23 09:18:41 +0000
committerNicholas Clark <nick@ccl4.org>2008-01-23 09:18:41 +0000
commitb68c599a1231c4d11ec0b0a667ce0c407c357eab (patch)
treed5ae12e45397be6d6266d7a947752951af4a968f /sv.c
parentd2aeed1648166d254ac68525c35b77dec4ba8772 (diff)
downloadperl-b68c599a1231c4d11ec0b0a667ce0c407c357eab.tar.gz
Fix the misplaced warnings and failing tests caused by the precision
loss warning on ++ and -- by moving the check to Configure time, creating a new config.sh variable nv_overflows_integers_at which contains an constant expression for the value of the NV which can't be incremented by 1.0 p4raw-id: //depot/perl@33049
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/sv.c b/sv.c
index 0618a8a158..a59af0d02e 100644
--- a/sv.c
+++ b/sv.c
@@ -6802,14 +6802,14 @@ Perl_sv_inc(pTHX_ register SV *sv)
}
if (flags & SVp_NOK) {
const NV was = SvNVX(sv);
- const NV now = was + 1.0;
- if (now - was != 1.0 && ckWARN(WARN_IMPRECISION)) {
+ if (NV_OVERFLOWS_INTEGERS_AT &&
+ was >= NV_OVERFLOWS_INTEGERS_AT && ckWARN(WARN_IMPRECISION)) {
Perl_warner(aTHX_ packWARN(WARN_IMPRECISION),
"Lost precision when incrementing %" NVff " by 1",
was);
}
(void)SvNOK_only(sv);
- SvNV_set(sv, now);
+ SvNV_set(sv, was + 1.0);
return;
}
@@ -6968,14 +6968,14 @@ Perl_sv_dec(pTHX_ register SV *sv)
oops_its_num:
{
const NV was = SvNVX(sv);
- const NV now = was - 1.0;
- if (now - was != -1.0 && ckWARN(WARN_IMPRECISION)) {
+ if (NV_OVERFLOWS_INTEGERS_AT &&
+ was <= -NV_OVERFLOWS_INTEGERS_AT && ckWARN(WARN_IMPRECISION)) {
Perl_warner(aTHX_ packWARN(WARN_IMPRECISION),
"Lost precision when decrementing %" NVff " by 1",
was);
}
(void)SvNOK_only(sv);
- SvNV_set(sv, now);
+ SvNV_set(sv, was - 1.0);
return;
}
}