summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorHugo van der Sanden <hv@crypt.org>2001-06-05 13:58:19 +0100
committerJarkko Hietaniemi <jhi@iki.fi>2001-06-05 23:19:19 +0000
commitbe484260a45925b3ceeebb752c3a7e6744c86450 (patch)
treee20a8e64079067800ff1fc42c489a12cd4518f40 /util.c
parentfa0a29af51ee3f14fc1952c7be0fe20aab57637f (diff)
downloadperl-be484260a45925b3ceeebb752c3a7e6744c86450.tar.gz
Re: [ID 20010529.006] String plus zero inconsistent across platforms
Message-Id: <200106051158.MAA04605@crypt.compulink.co.uk> p4raw-id: //depot/perl@10445
Diffstat (limited to 'util.c')
-rw-r--r--util.c29
1 files changed, 12 insertions, 17 deletions
diff --git a/util.c b/util.c
index f40f5b9612..e034c33ce5 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*