aboutsummaryrefslogtreecommitdiff
path: root/bignum.h
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2016-01-17 04:08:52 -0500
committerB. Watson <yalhcru@gmail.com>2016-01-17 04:08:52 -0500
commitd72f8556e703eb8c84d055bfc5a8dcb2620ad61e (patch)
tree51326271fb66ee562b42911422c35ec9b28be362 /bignum.h
parentb9c1931a80c5d700ba356f9090e9a72f075377f7 (diff)
downloadtaipan-d72f8556e703eb8c84d055bfc5a8dcb2620ad61e.tar.gz
restore colors/font on exit, fix bank withdrawal bug, rename bignum stuff
Diffstat (limited to 'bignum.h')
-rw-r--r--bignum.h49
1 files changed, 17 insertions, 32 deletions
diff --git a/bignum.h b/bignum.h
index 501d47c..4bf754c 100644
--- a/bignum.h
+++ b/bignum.h
@@ -21,34 +21,21 @@
which looks a little weird I admit.
*/
-#define bignum(x) char x[6]
-#define bignump char *
-
-/****** constants ******/
-/* zero */
-#define BIG_0 { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
-
-/* TODO: calculate bank interest differently: this bignum
- implementation is floating point, but I might swap it out
- for an int-based one! */
-/* 1.005 (bank interest) */
-#define BIG_1_005 { 0x40, 0x01, 0x00, 0x50, 0x00, 0x00 }
-
-/* bignum 100, used for score calculations in final_stats() */
-#define BIG_100 { 0x41, 0x01, 0x00, 0x00, 0x00, 0x00 }
-
-/* one thousand, one million, one hundred million */
-#define BIG_1K { 0x41, 0x10, 0x00, 0x00, 0x00, 0x00 }
-#define BIG_1M { 0x43, 0x01, 0x00, 0x00, 0x00, 0x00 }
-#define BIG_100M { 0x44, 0x01, 0x00, 0x00, 0x00, 0x00 }
-
-/* 10 million, one billion, one trillion */
-#define BIG_10M { 0x43, 0x10, 0x00, 0x00, 0x00, 0x00 }
-#define BIG_1B { 0x44, 0x10, 0x00, 0x00, 0x00, 0x00 }
-#define BIG_1T { 0x46, 0x01, 0x00, 0x00, 0x00, 0x00 }
-
-/* max value for a ulong */
-#define BIG_MAX_ULONG { 0x44, 0x42, 0x94, 0x96, 0x72, 0x95 }
+/* list all our implementations here */
+#define BIGFLOAT 1
+#define BIGINT48 2
+
+#ifndef BIGNUM
+#error bignum.h requires BIGNUM to be defined
+#endif
+
+#if BIGNUM == BIGFLOAT
+#include "bigfloat.h"
+#elif BIGNUM == BIGINT48
+#include "bigint48.h"
+#else
+#error BIGNUM must be defined to one of: BIGFLOAT BIGINT48
+#endif
/****** functions ******/
@@ -92,7 +79,7 @@ extern char __cdecl__ big_sub(bignump dest, bignump minuend, bignump subtrahend)
extern char __cdecl__ big_mul(bignump dest, bignump multiplicand, bignump multiplier);
extern char __cdecl__ big_div(bignump dest, bignump dividend, bignump divisor);
-/* dest = src * -1 */
+/* negation: dest = src * -1, or dest = -src if you prefer. */
extern void __fastcall__ big_negate(bignump dest, bignump src);
/* returns true if the bank is maxed out. We do this by checking the exponent
@@ -105,7 +92,5 @@ extern void __fastcall__ big_negate(bignump dest, bignump src);
*/
extern char __fastcall__ bank_maxed_out(bignump b);
-// signed char big_cmp(const bignum *a, const bignum *b)
-
-extern unsigned long cformat_big(char *magnitude, bignump b);
+/* print a bignum, Taipan-style. Code for this lives in taipan.c actually. */
extern void cprintfancy_big(bignump b);