summaryrefslogtreecommitdiff
path: root/numeric.c
diff options
context:
space:
mode:
authorMichael G. Schwern <schwern@pobox.com>2020-12-28 18:04:52 -0800
committerKarl Williamson <khw@cpan.org>2021-01-17 09:18:15 -0700
commit1604cfb0273418ed479719f39def5ee559bffda2 (patch)
tree166a5ab935a029ab86cf6295d6f3cb77da22e559 /numeric.c
parent557ff1b2a4ecd18fe9229e7e0eb8fa123adc5670 (diff)
downloadperl-1604cfb0273418ed479719f39def5ee559bffda2.tar.gz
style: Detabify indentation of the C code maintained by the core.
This just detabifies to get rid of the mixed tab/space indentation. Applying consistent indentation and dealing with other tabs are another issue. Done with `expand -i`. * vutil.* left alone, it's part of version. * Left regen managed files alone for now.
Diffstat (limited to 'numeric.c')
-rw-r--r--numeric.c220
1 files changed, 110 insertions, 110 deletions
diff --git a/numeric.c b/numeric.c
index 349048cdcb..72130dd9f5 100644
--- a/numeric.c
+++ b/numeric.c
@@ -1367,9 +1367,9 @@ S_mulexp10(NV value, I32 exponent)
I32 bit;
if (exponent == 0)
- return value;
+ return value;
if (value == 0)
- return (NV)0;
+ return (NV)0;
/* On OpenVMS VAX we by default use the D_FLOAT double format,
* and that format does not have *easy* capabilities [1] for
@@ -1393,24 +1393,24 @@ S_mulexp10(NV value, I32 exponent)
#if ((defined(VMS) && !defined(_IEEE_FP)) || defined(_UNICOS) || defined(DOUBLE_IS_VAX_FLOAT)) && defined(NV_MAX_10_EXP)
STMT_START {
- const NV exp_v = log10(value);
- if (exponent >= NV_MAX_10_EXP || exponent + exp_v >= NV_MAX_10_EXP)
- return NV_MAX;
- if (exponent < 0) {
- if (-(exponent + exp_v) >= NV_MAX_10_EXP)
- return 0.0;
- while (-exponent >= NV_MAX_10_EXP) {
- /* combination does not overflow, but 10^(-exponent) does */
- value /= 10;
- ++exponent;
- }
- }
+ const NV exp_v = log10(value);
+ if (exponent >= NV_MAX_10_EXP || exponent + exp_v >= NV_MAX_10_EXP)
+ return NV_MAX;
+ if (exponent < 0) {
+ if (-(exponent + exp_v) >= NV_MAX_10_EXP)
+ return 0.0;
+ while (-exponent >= NV_MAX_10_EXP) {
+ /* combination does not overflow, but 10^(-exponent) does */
+ value /= 10;
+ ++exponent;
+ }
+ }
} STMT_END;
#endif
if (exponent < 0) {
- negative = 1;
- exponent = -exponent;
+ negative = 1;
+ exponent = -exponent;
#ifdef NV_MAX_10_EXP
/* for something like 1234 x 10^-309, the action of calculating
* the intermediate value 10^309 then returning 1234 / (10^309)
@@ -1433,9 +1433,9 @@ S_mulexp10(NV value, I32 exponent)
# define FP_OVERFLOWS_TO_ZERO
#endif
for (bit = 1; exponent; bit <<= 1) {
- if (exponent & bit) {
- exponent ^= bit;
- result *= power;
+ if (exponent & bit) {
+ exponent ^= bit;
+ result *= power;
#ifdef FP_OVERFLOWS_TO_ZERO
if (result == 0)
# ifdef NV_INF
@@ -1444,12 +1444,12 @@ S_mulexp10(NV value, I32 exponent)
return value < 0 ? -FLT_MAX : FLT_MAX;
# endif
#endif
- /* Floating point exceptions are supposed to be turned off,
- * but if we're obviously done, don't risk another iteration.
- */
- if (exponent == 0) break;
- }
- power *= power;
+ /* Floating point exceptions are supposed to be turned off,
+ * but if we're obviously done, don't risk another iteration.
+ */
+ if (exponent == 0) break;
+ }
+ power *= power;
}
return negative ? value / result : value * result;
}
@@ -1646,15 +1646,15 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, const STRLEN len)
/* leading whitespace */
while (s < send && isSPACE(*s))
- ++s;
+ ++s;
/* sign */
switch (*s) {
- case '-':
- negative = 1;
- /* FALLTHROUGH */
- case '+':
- ++s;
+ case '-':
+ negative = 1;
+ /* FALLTHROUGH */
+ case '+':
+ ++s;
}
#endif
@@ -1744,102 +1744,102 @@ Perl_my_atof3(pTHX_ const char* orig, NV* value, const STRLEN len)
* large, we add the total to NV and start again */
while (s < send) {
- if (isDIGIT(*s)) {
- seen_digit = 1;
- old_digit = digit;
- digit = *s++ - '0';
- if (seen_dp)
- exp_adjust[1]++;
-
- /* don't start counting until we see the first significant
- * digit, eg the 5 in 0.00005... */
- if (!sig_digits && digit == 0)
- continue;
-
- if (++sig_digits > MAX_SIG_DIGITS) {
- /* limits of precision reached */
- if (digit > 5) {
- ++accumulator[seen_dp];
- } else if (digit == 5) {
- if (old_digit % 2) { /* round to even - Allen */
- ++accumulator[seen_dp];
- }
- }
- if (seen_dp) {
- exp_adjust[1]--;
- } else {
- exp_adjust[0]++;
- }
- /* skip remaining digits */
- while (s < send && isDIGIT(*s)) {
- ++s;
- if (! seen_dp) {
- exp_adjust[0]++;
- }
- }
- /* warn of loss of precision? */
- }
- else {
- if (accumulator[seen_dp] > MAX_ACCUMULATE) {
- /* add accumulator to result and start again */
- result[seen_dp] = S_mulexp10(result[seen_dp],
- exp_acc[seen_dp])
- + (NV)accumulator[seen_dp];
- accumulator[seen_dp] = 0;
- exp_acc[seen_dp] = 0;
- }
- accumulator[seen_dp] = accumulator[seen_dp] * 10 + digit;
- ++exp_acc[seen_dp];
- }
- }
- else if (!seen_dp && GROK_NUMERIC_RADIX(&s, send)) {
- seen_dp = 1;
- if (sig_digits > MAX_SIG_DIGITS) {
- while (s < send && isDIGIT(*s)) {
- ++s;
- }
- break;
- }
- }
- else {
- break;
- }
+ if (isDIGIT(*s)) {
+ seen_digit = 1;
+ old_digit = digit;
+ digit = *s++ - '0';
+ if (seen_dp)
+ exp_adjust[1]++;
+
+ /* don't start counting until we see the first significant
+ * digit, eg the 5 in 0.00005... */
+ if (!sig_digits && digit == 0)
+ continue;
+
+ if (++sig_digits > MAX_SIG_DIGITS) {
+ /* limits of precision reached */
+ if (digit > 5) {
+ ++accumulator[seen_dp];
+ } else if (digit == 5) {
+ if (old_digit % 2) { /* round to even - Allen */
+ ++accumulator[seen_dp];
+ }
+ }
+ if (seen_dp) {
+ exp_adjust[1]--;
+ } else {
+ exp_adjust[0]++;
+ }
+ /* skip remaining digits */
+ while (s < send && isDIGIT(*s)) {
+ ++s;
+ if (! seen_dp) {
+ exp_adjust[0]++;
+ }
+ }
+ /* warn of loss of precision? */
+ }
+ else {
+ if (accumulator[seen_dp] > MAX_ACCUMULATE) {
+ /* add accumulator to result and start again */
+ result[seen_dp] = S_mulexp10(result[seen_dp],
+ exp_acc[seen_dp])
+ + (NV)accumulator[seen_dp];
+ accumulator[seen_dp] = 0;
+ exp_acc[seen_dp] = 0;
+ }
+ accumulator[seen_dp] = accumulator[seen_dp] * 10 + digit;
+ ++exp_acc[seen_dp];
+ }
+ }
+ else if (!seen_dp && GROK_NUMERIC_RADIX(&s, send)) {
+ seen_dp = 1;
+ if (sig_digits > MAX_SIG_DIGITS) {
+ while (s < send && isDIGIT(*s)) {
+ ++s;
+ }
+ break;
+ }
+ }
+ else {
+ break;
+ }
}
result[0] = S_mulexp10(result[0], exp_acc[0]) + (NV)accumulator[0];
if (seen_dp) {
- result[1] = S_mulexp10(result[1], exp_acc[1]) + (NV)accumulator[1];
+ result[1] = S_mulexp10(result[1], exp_acc[1]) + (NV)accumulator[1];
}
if (s < send && seen_digit && (isALPHA_FOLD_EQ(*s, 'e'))) {
- bool expnegative = 0;
-
- ++s;
- switch (*s) {
- case '-':
- expnegative = 1;
- /* FALLTHROUGH */
- case '+':
- ++s;
- }
- while (s < send && isDIGIT(*s))
- exponent = exponent * 10 + (*s++ - '0');
- if (expnegative)
- exponent = -exponent;
+ bool expnegative = 0;
+
+ ++s;
+ switch (*s) {
+ case '-':
+ expnegative = 1;
+ /* FALLTHROUGH */
+ case '+':
+ ++s;
+ }
+ while (s < send && isDIGIT(*s))
+ exponent = exponent * 10 + (*s++ - '0');
+ if (expnegative)
+ exponent = -exponent;
}
/* now apply the exponent */
if (seen_dp) {
- result[2] = S_mulexp10(result[0],exponent+exp_adjust[0])
- + S_mulexp10(result[1],exponent-exp_adjust[1]);
+ result[2] = S_mulexp10(result[0],exponent+exp_adjust[0])
+ + S_mulexp10(result[1],exponent-exp_adjust[1]);
} else {
- result[2] = S_mulexp10(result[0],exponent+exp_adjust[0]);
+ result[2] = S_mulexp10(result[0],exponent+exp_adjust[0]);
}
/* now apply the sign */
if (negative)
- result[2] = -result[2];
+ result[2] = -result[2];
*value = result[2];
return (char *)s;
#else /* USE_PERL_ATOF */