X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=util.c;h=ecaf18ba026d59067ac15344724117defc493850;hb=7b57b0ead8ab6b3f08be8b4ded2364d260db25a1;hp=f40f5b96124245b21a29d2240d6f46763c760ad8;hpb=a87ab2ebad5f814f5d93f568156eb348cfb1a1a3;p=p5sagit%2Fp5-mst-13.2.git diff --git a/util.c b/util.c index f40f5b9..ecaf18b 100644 --- a/util.c +++ b/util.c @@ -4036,30 +4036,25 @@ Perl_my_atof(pTHX_ const char* s) NV S_mulexp10(NV value, I32 exponent) { - NV result = value; + NV result = 1.0; NV power = 10.0; + bool negative = 0; I32 bit; - if (exponent > 0) { - for (bit = 1; exponent; bit <<= 1) { - if (exponent & bit) { - exponent ^= bit; - result *= power; - } - power *= power; - } - } + if (exponent == 0) + return value; else if (exponent < 0) { + negative = 1; exponent = -exponent; - for (bit = 1; exponent; bit <<= 1) { - if (exponent & bit) { - exponent ^= bit; - result /= power; - } - power *= power; + } + for (bit = 1; exponent; bit <<= 1) { + if (exponent & bit) { + exponent ^= bit; + result *= power; } + power *= power; } - return result; + return negative ? value / result : value * result; } char* @@ -4087,8 +4082,10 @@ Perl_my_atof2(pTHX_ const char* orig, NV* value) I32 ipart = 0; /* index into part[] */ I32 offcount; /* number of digits in least significant part */ - if (PL_numeric_radix_sv) +#ifdef USE_LOCALE_NUMERIC + if (PL_numeric_radix_sv && IN_LOCALE) point = SvPV(PL_numeric_radix_sv, pointlen); +#endif /* sign */ switch (*s) {