develooper Front page | perl.perl5.porters | Postings from December 2004

Re: modf chainsaw?

Thread Previous
Ed Allen Smith
December 14, 2004 03:24
Re: modf chainsaw?
Message ID:
In message <> (on 14 December 2004 03:14:30
-0800), (Yitzchak Scott-Thoennes) wrote:
>On Tue, Dec 14, 2004 at 05:59:00AM -0500, Ed Allen Smith
><> wrote:
>> In message <> (on 14 December 2004 01:49:30
>> -0800), (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:
>Yeah, I saw that, but couldn't make heads or tails of when an (IV) cast
>would produce a different number than modf.  Both should truncate zeroward.
>Neither should involve any rounding at all.

I've seen what I suspected to be wacked long double casting results in IRIX,
although that was when casting to a double and I never did trace back enough
to find out what the exact problem was (I was attempting some tinkering on
gsl and concluded that I was more likely to mess it up than help it be more
accurate by lessening internal rounding).

>But I had meant to note it and that pp_int used to be another modf
>consumer (5.8.0 and earlier).


>> 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.  */

Allen Smith		
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 Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About