From: Jens Hamisch Date: Tue, 17 Oct 2000 08:39:36 +0000 (+0200) Subject: Don't write double values through long double pointers, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1048ea30476937814737f4fb47f5b4cb2620fbb6;p=p5sagit%2Fp5-mst-13.2.git Don't write double values through long double pointers, based on a part of Subject: [ID 20001016.017] [jens: 5.7.0 Solaris 8, 64 Bit, Workshop 6.0 Compiler] Message-Id: <20001017083936.A11104@Strawberry.COM> p4raw-id: //depot/perl@7380 --- diff --git a/perl.h b/perl.h index b655e04..97fbac2 100644 --- a/perl.h +++ b/perl.h @@ -1075,6 +1075,9 @@ typedef UVTYPE UV; #endif #ifdef USE_LONG_DOUBLE +# if defined(HAS_LONG_DOUBLE) && LONG_DOUBLESIZE == DOUBLESIZE +# define LONG_DOUBLE_EQUALS_DOUBLE +# endif # if !(defined(HAS_LONG_DOUBLE) && (LONG_DOUBLESIZE > DOUBLESIZE)) # undef USE_LONG_DOUBLE /* Ouch! */ # endif @@ -1184,13 +1187,9 @@ typedef NVTYPE NV; /* e.g. libsunmath doesn't have modfl and frexpl as of mid-March 2000 */ # ifdef HAS_MODFL # define Perl_modf(x,y) modfl(x,y) -# else -# define Perl_modf(x,y) ((long double)modf((double)(x),(double*)(y))) # endif # ifdef HAS_FREXPL # define Perl_frexp(x,y) frexpl(x,y) -# else -# define Perl_frexp(x,y) ((long double)frexp((double)(x),y)) # endif # ifdef HAS_ISNANL # define Perl_isnan(x) isnanl(x) diff --git a/pp.c b/pp.c index 9afa96d..98d31cb 100644 --- a/pp.c +++ b/pp.c @@ -1889,11 +1889,24 @@ PP(pp_int) SETi(iv); } else { - if (value >= 0.0) - (void)Perl_modf(value, &value); + if (value >= 0.0) { +#if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE) + (void)Perl_modf(value, &value); +#else + double tmp = (double)value; + (void)Perl_modf(tmp, &tmp); + value = (NV)tmp; +#endif + } else { - (void)Perl_modf(-value, &value); - value = -value; +#if defined(HAS_MODFL) || defined(LONG_DOUBLE_EQUALS_DOUBLE) + (void)Perl_modf(-value, &value); + value = -value; +#else + double tmp = (double)value; + (void)Perl_modf(-tmp, &tmp); + value = -(NV)tmp; +#endif } iv = I_V(value); if (iv == value)