diff options
author | Gavin Howard <yzena.tech@gmail.com> | 2019-05-07 10:32:39 -0600 |
---|---|---|
committer | Gavin Howard <yzena.tech@gmail.com> | 2019-05-07 10:32:39 -0600 |
commit | e34f7d8fe90f76c93ed51100e459fcc54e2b893a (patch) | |
tree | 61d0f4c22f802ec85c8d89168790680021f940bf | |
parent | 959d54bea0536cbf5087ab5739f2641a4c8dfbfd (diff) | |
download | platform_external_bc-e34f7d8fe90f76c93ed51100e459fcc54e2b893a.tar.gz platform_external_bc-e34f7d8fe90f76c93ed51100e459fcc54e2b893a.tar.bz2 platform_external_bc-e34f7d8fe90f76c93ed51100e459fcc54e2b893a.zip |
Fix a few various things
-rwxr-xr-x | configure.sh | 6 | ||||
-rw-r--r-- | include/num.h | 11 | ||||
-rwxr-xr-x | karatsuba.py | 2 | ||||
-rw-r--r-- | src/num.c | 3 |
4 files changed, 14 insertions, 8 deletions
diff --git a/configure.sh b/configure.sh index eb20720d..6a4765e2 100755 --- a/configure.sh +++ b/configure.sh @@ -279,7 +279,7 @@ gen_file_lists() { bc_only=0 dc_only=0 coverage=0 -karatsuba_len=64 +karatsuba_len=32 debug=0 signals=1 hist=1 @@ -414,8 +414,8 @@ case $karatsuba_len in (*) ;; esac -if [ "$karatsuba_len" -lt 16 ]; then - usage "KARATSUBA_LEN is less than 16" +if [ "$karatsuba_len" -lt 2 ]; then + usage "KARATSUBA_LEN is less than 2" fi set -e diff --git a/include/num.h b/include/num.h index 337d1154..f87ba75d 100644 --- a/include/num.h +++ b/include/num.h @@ -67,6 +67,7 @@ typedef int_least32_t BcDig; #define BC_BASE_POWER (9) #define BC_BASE_DIG (1000000000) +#define BC_NUM_DEF_SIZE (2) #elif BC_LONG_BIT >= 32 // sizeof(long) has been guaranteed to be at least 32 bit long since at least c99 @@ -76,6 +77,7 @@ typedef int_least16_t BcDig; #define BC_BASE_POWER (4) #define BC_BASE_DIG (10000) +#define BC_NUM_DEF_SIZE (4) #else @@ -85,11 +87,13 @@ typedef int_least8_t BcDig; #define BC_BASE_POWER (2) #define BC_BASE_DIG (100) +#define BC_NUM_DEF_SIZE (8) #elif BC_LONG_BIT >= 8 #define BC_BASE_POWER (1) #define BC_BASE_DIG (10) +#define BC_NUM_DEF_SIZE (16) #else @@ -112,13 +116,12 @@ typedef struct BcNum { #define BC_NUM_MAX_IBASE ((unsigned long) 36) // This is the max base allowed by bc_num_parseChar(). #define BC_NUM_MAX_LBASE ('Z' + BC_BASE + 1) -#define BC_NUM_DEF_SIZE (2) #define BC_NUM_PRINT_WIDTH (69) #ifndef BC_NUM_KARATSUBA_LEN -#define BC_NUM_KARATSUBA_LEN (128) -#elif BC_NUM_KARATSUBA_LEN < 16 -#error BC_NUM_KARATSUBA_LEN must be at least 16 +#define BC_NUM_KARATSUBA_LEN (32) +#elif BC_NUM_KARATSUBA_LEN < BC_NUM_DEF_SIZE +#error BC_NUM_KARATSUBA_LEN must be at least equal to BC_NUM_DEF_SIZE. #endif // BC_NUM_KARATSUBA_LEN // A crude, but always big enough, calculation of diff --git a/karatsuba.py b/karatsuba.py index 28321e8b..96d175c5 100755 --- a/karatsuba.py +++ b/karatsuba.py @@ -50,7 +50,7 @@ if __name__ != "__main__": mx = 520 mx2 = mx // 2 -mn = 16 +mn = 2 num = "9" * mx @@ -2443,6 +2443,7 @@ void bc_num_printDebug(const BcNum *n, const char *name, bool emptyline) { bc_num_printDecimal(n); printf("\n"); if (emptyline) printf("\n"); + vm->nchars = 0; } void bc_num_printDigs(const BcNum *n, const char *name, bool emptyline) { @@ -2457,6 +2458,7 @@ void bc_num_printDigs(const BcNum *n, const char *name, bool emptyline) { printf("\n"); if (emptyline) printf("\n"); + vm->nchars = 0; } void bc_num_dump(const char *varname, const BcNum *n) { @@ -2489,5 +2491,6 @@ void bc_num_dump(const char *varname, const BcNum *n) { fprintf(stderr, "(%zu | %zu.%zu / %zu) %p\n", n->scale, n->len, n->rdx, n->cap, (void*) n->num); + vm->nchars = 0; } #endif // BC_DEBUG_CODE |