Front page | perl.perl5.porters |
Postings from December 2004
Re: modf chainsaw?
Thread Previous
|
Thread Next
From:
Ed Allen Smith
Date:
December 14, 2004 02:54
Subject:
Re: modf chainsaw?
Message ID:
mid+200412141059.iBEAx1qj1006214@dogberry.rutgers.edu
In message <20041214094930.GB756@efn.org> (on 14 December 2004 01:49:30
-0800), sthoenna@efn.org (Yitzchak Scott-Thoennes) wrote:
>It looks to me like the only use of modfl? is now in pp_pack.c, and that
>looks like a bizarre kind of way to do something by someone who didn't
>know that fmod existed.
>
>Can someone who has some idea what the uuencode unpacking code is doing
>comment on whether this:
>
> cdouble = Perl_modf(cdouble / adouble, &trouble) * adouble;
>
>can't be this instead:
>
> cdouble = Perl_fmod(cdouble, adouble);
>
>Then the Perl_modfl stuff in numeric.c can be ripped out, and the
>requirement for modfl for using long doubles can be removed from
>Configure.
OTOH:
PP(pp_int)
{
dSP; dTARGET; tryAMAGICun(int);
{
NV value;
IV iv = TOPi; /* attempt to convert to IV if possible. */
/* XXX it's arguable that compiler casting to IV might be subtly
different from modf (for numbers inside (IV_MIN,UV_MAX)) in which
else preferring IV has introduced a subtle behaviour change bug. OTOH
relying on floating point to be accurate is a bug. */
if (!SvOK(TOPs))
SETu(0);
else if (SvIOK(TOPs)) {
if (SvIsUV(TOPs)) {
UV uv = TOPu;
SETu(uv);
} else
SETi(iv);
} else {
value = TOPn;
if (value >= 0.0) {
if (value < (NV)UV_MAX + 0.5) {
SETu(U_V(value));
} else {
SETn(Perl_floor(value));
}
}
else {
if (value > (NV)IV_MIN - 0.5) {
SETi(I_V(value));
} else {
SETn(Perl_ceil(value));
}
}
}
}
RETURN;
}
--
Allen Smith http://cesario.rutgers.edu/easmith/
There is only one sound argument for democracy, and that is the argument
that it is a crime for any man to hold himself out as better than other men,
and, above all, a most heinous offense for him to prove it. - H. L. Mencken
Thread Previous
|
Thread Next
-
modf chainsaw?
by Yitzchak Scott-Thoennes
-
Re: modf chainsaw?
by Ed Allen Smith