}
}
-static BC_STATUS zbc_num_ulong(BcNum *n, unsigned long *result_p)
+static BC_STATUS zbc_num_ulong_abs(BcNum *n, unsigned long *result_p)
{
size_t i;
unsigned long result;
- if (n->neg) RETURN_STATUS(bc_error("negative number"));
-
result = 0;
i = n->len;
while (i > n->rdx) {
RETURN_STATUS(BC_STATUS_SUCCESS);
}
+#define zbc_num_ulong_abs(...) (zbc_num_ulong_abs(__VA_ARGS__) COMMA_SUCCESS)
+
+static BC_STATUS zbc_num_ulong(BcNum *n, unsigned long *result_p)
+{
+ if (n->neg) RETURN_STATUS(bc_error("negative number"));
+
+ RETURN_STATUS(zbc_num_ulong_abs(n, result_p));
+}
#define zbc_num_ulong(...) (zbc_num_ulong(__VA_ARGS__) COMMA_SUCCESS)
#if ULONG_MAX == 0xffffffffUL // 10 digits: 4294967295
}
neg = b->neg;
- b->neg = false;
- s = zbc_num_ulong(b, &pow);
- b->neg = neg;
+ s = zbc_num_ulong_abs(b, &pow);
if (s) RETURN_STATUS(s);
// b is not used beyond this point
char *str;
char c;
size_t idx;
- unsigned long val;
if (!STACK_HAS_MORE_THAN(&G.prog.results, 0))
RETURN_STATUS(bc_error_stack_has_too_few_elements());
if (s) RETURN_STATUS(s);
if (BC_PROG_NUM(r, num)) {
+ unsigned long val;
BcNum strmb;
BcDig strmb_digs[ULONG_NUM_BUFSIZE];