#if defined(NAN_COMPARE_BROKEN) && defined(Perl_isnan)
if (! Perl_isnan(right) && right == 0.0)
#else
- if (right == 0.0)
+ if (NV_eq_nowarn(right, 0.0))
#endif
DIE(aTHX_ "Illegal division by zero");
PUSHn( left / right );
if (use_double) {
NV dans;
- if (!dright)
+ if (NV_eq_nowarn(dright, 0.0))
DIE(aTHX_ "Illegal modulus zero");
dans = Perl_fmod(dleft, dright);
- if ((left_neg != right_neg) && dans)
+ if ((left_neg != right_neg) && NV_ne_nowarn(dans, 0.0))
dans = dright - dans;
if (right_neg)
dans = -dans;
return -1;
if (lnv > rnv)
return 1;
- if (lnv == rnv)
+ if (NV_eq_nowarn(lnv, rnv))
return 0;
return 2;
#endif
value = SvNV(sv);
}
/* 1 of 2 things can be carried through SvNV, SP or TARG, SP was carried */
- if (value == 0.0)
+ if (NV_eq_nowarn(value, 0.0))
value = 1.0;
{
dTARGET;
sv_2iv */
if (SvNVX(sv) <= (UV)IV_MAX) {
SvIV_set(sv, I_V(SvNVX(sv)));
- if ((NV)(SvIVX(sv)) == SvNVX(sv)) {
+ if (NV_eq_nowarn((NV)(SvIVX(sv)), SvNVX(sv))) {
SvIOK_on(sv); /* Integer is precise. NOK, IOK */
} else {
/* Integer is imprecise. NOK, IOKp */
}
SvIsUV_on(sv);
SvUV_set(sv, U_V(SvNVX(sv)));
- if ((NV)(SvUVX(sv)) == SvNVX(sv)) {
+ if (NV_eq_nowarn((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.
#endif
if (SvNVX(sv) < (NV)IV_MAX + 0.5) {
SvIV_set(sv, I_V(SvNVX(sv)));
- if (SvNVX(sv) == (NV) SvIVX(sv)
+ if (NV_eq_nowarn(SvNVX(sv), (NV)SvIVX(sv))
#ifndef NV_PRESERVES_UV
&& (((UV)1 << NV_PRESERVES_UV_BITS) >
(UV)(SvIVX(sv) > 0 ? SvIVX(sv) : -SvIVX(sv)))
else {
SvUV_set(sv, U_V(SvNVX(sv)));
if (
- (SvNVX(sv) == (NV) SvUVX(sv))
+ (NV_eq_nowarn(SvNVX(sv), (NV) SvUVX(sv)))
#ifndef NV_PRESERVES_UV
/* Make sure it's not 0xFFFFFFFFFFFFFFFF */
/*&& (SvUVX(sv) != UV_MAX) irrelevant with code below */
(void)SvIOKp_on(sv);
SvNOK_on(sv);
SvIV_set(sv, I_V(SvNVX(sv)));
- if ((NV)(SvIVX(sv)) == SvNVX(sv))
+ if (NV_eq_nowarn((NV)(SvIVX(sv)), SvNVX(sv)))
SvIOK_on(sv);
/* Assumption: first non-preserved integer is < IV_MAX,
this NV is in the preserved range, therefore: */
else if (SvNOK(sv)) {
if (SvTYPE(sv) < SVt_PVNV)
sv_upgrade(sv, SVt_PVNV);
- if (SvNVX(sv) == 0.0) {
+ if (NV_eq_nowarn(SvNVX(sv), 0.0)) {
s = SvGROW_mutable(sv, 2);
*s++ = '0';
*s = '\0';
}
else if((SvFLAGS(sv) & (SVf_IOK|SVf_NOK))) {
svb = (SvIOK(sv) && SvIVX(sv) != 0)
- || (SvNOK(sv) && SvNVX(sv) != 0.0);
+ || (SvNOK(sv) && NV_ne_nowarn(SvNVX(sv), 0.0));
}
else {
flags = 0;
}
if (flags & SVp_NOK) {
const NV was = SvNVX(sv);
- if (NV_OVERFLOWS_INTEGERS_AT &&
- was >= NV_OVERFLOWS_INTEGERS_AT) {
+ if (NV_OVERFLOWS_INTEGERS_AT > 0 &&
+ !(was < NV_OVERFLOWS_INTEGERS_AT)) {
/* diag_listed_as: Lost precision when %s %f by 1 */
Perl_ck_warner(aTHX_ packWARN(WARN_IMPRECISION),
"Lost precision when incrementing %" NVff " by 1",
oops_its_num:
{
const NV was = SvNVX(sv);
- if (NV_OVERFLOWS_INTEGERS_AT &&
- was <= -NV_OVERFLOWS_INTEGERS_AT) {
+ if (NV_OVERFLOWS_INTEGERS_AT > 0 &&
+ !(was > -NV_OVERFLOWS_INTEGERS_AT)) {
/* diag_listed_as: Lost precision when %s %f by 1 */
Perl_ck_warner(aTHX_ packWARN(WARN_IMPRECISION),
"Lost precision when decrementing %" NVff " by 1",
return SvIVX(sv) != 0;
else {
if (SvNOK(sv))
- return SvNVX(sv) != 0.0;
+ return NV_ne_nowarn(SvNVX(sv), 0.0);
else
return sv_2bool(sv);
}
char *p = endbuf;
nv += 0.5;
uv = (UV)nv;
- if (uv & 1 && uv == nv)
+ if (uv & 1 && NV_eq_nowarn(uv, nv))
uv--; /* Round to even */
do {
const unsigned dig = uv % 10;