From b7220bcd1a054872e081afc77b305f0247bf3f98 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Mon, 28 Mar 2022 16:47:04 -0400 Subject: group functions by funcionality --- big.h | 51 ++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/big.h b/big.h index 760944d..9eb1406 100644 --- a/big.h +++ b/big.h @@ -22,29 +22,50 @@ #define getsmallint(x) (hd[x]&SIGNBIT?-digit0(x):digit(x)) #define stosmallint(x) make(INT,(x)<0?SIGNBIT|(-(x)):(x),0) -long long big_toll(word); +/* initialization */ +void bigsetup(void); + +/* convert between big int and long long */ word big_fromll(long long); +long long big_toll(word); + +/* convert between big int and double */ +word big_fromd(double); double big_tod(word); + +/* unary negation */ +word big_negate(word); + +/* compare two big ints */ +int big_compare(word, word); + +/* basic arithmetic */ +word big_add(word, word); +word big_subtract(word, word); +word big_multiply(word, word); +word big_divide(word, word); +word big_remainder(word, word); + +/* logarithms and exponentiation */ double big_log(word); double big_log10(word); -int big_compare(word,word); -word big_divide(word, word); -word big_remainder(word,word); -word big_negate(word); -word bigoscan(char *,char *); -word big_add(word,word); -word big_pow(word,word); -word bigscan(char *); -void bigsetup(void); -word big_subtract(word,word); -word big_multiply(word,word); +word big_pow(word, word); + +/* TODO: combine to make big_tostr(word big, int base) */ word bigtostr(word); word bigtostr8(word); word bigtostrx(word); -word bigxscan(char *,char *); -word big_fromd(double); + +/* TODO: rename big_fromstr() */ +word strtobig(word, int); + +/* TODO: combine to make big_scan(char *, ?char*?, int base) */ +word bigscan(char *); +word bigoscan(char *, char *); +word bigxscan(char *, char *); + +/* TODO: better name and documentation */ int isnat(word); -word strtobig(word,int); #define force_dbl(x) ((tag[(x)] == INT) ? big_tod((x)) : get_dbl((x))) -- cgit v1.2.1