aboutsummaryrefslogtreecommitdiff
path: root/taipan.c
diff options
context:
space:
mode:
Diffstat (limited to 'taipan.c')
-rw-r--r--taipan.c45
1 files changed, 20 insertions, 25 deletions
diff --git a/taipan.c b/taipan.c
index d58a818..97d2271 100644
--- a/taipan.c
+++ b/taipan.c
@@ -333,7 +333,14 @@ void cprintfancy_big(bignump b) {
unsigned long leftdigits = 0L;
unsigned char rightdigits = 0, letter = 'M', leading0 = 0;
- if(big_cmp(b, big1T) >= 0) {
+ big_copy(tmp, b);
+
+ if(big_cmp(tmp, big0) < 0) {
+ cputc('-');
+ big_negate(tmp, tmp);
+ }
+
+ if(big_cmp(tmp, big1T) >= 0) {
revers(1);
cputs("1 Trillion+!");
revers(0);
@@ -341,16 +348,14 @@ void cprintfancy_big(bignump b) {
}
/* for >= 1B, divide by 1M */
- if(big_cmp(b, big1B) >= 0) {
- big_div(tmp, b, big1K);
+ if(big_cmp(tmp, big1B) >= 0) {
+ big_div(tmp, tmp, big1K);
letter = 'B';
- } else {
- big_copy(tmp, b);
}
big_to_ulong(tmp, &leftdigits);
- if(big_cmp(b, big1M) < 0) { /* 0..999999 */
+ if(big_cmp(tmp, big1M) < 0) { /* 0..999999 */
letter = 0;
} else if(leftdigits < 10000000L) { /* 1M..10M-1 */
leftdigits /= 10000L;
@@ -1707,10 +1712,14 @@ void final_stats(void)
ulong_to_big((unsigned long)time, bigtmp);
big_div(bigscore, bigscore, bigtmp);
- if(big_cmp(bigscore, big1M) > 0)
+ if(big_cmp(bigscore, big1M) > 0) {
score = 1000000L;
- else
+ } else if(big_cmp(bigscore, big0) < 0) {
+ score = -1;
+ } else {
big_to_ulong(bigscore, (unsigned long*)&score);
+ }
+
#else
/* TODO: write cprintlong() to print signed value */
long finalcash = cash + bank - debt;
@@ -2731,28 +2740,11 @@ void buy(void) {
cputs(" ");
gotoxy(31, 23);
- /* TODO: is this really right? */
if(afford < 100) cputc(' ');
if(afford < 10000) cputc(' ');
if(afford < 1000000) cputc(' ');
if(afford < 100000000) cputc(' ');
- /*
- if (afford < 100)
- {
- strcpy(space, " ");
- } else if (afford < 10000) {
- strcpy(space, " ");
- } else if (afford < 1000000) {
- strcpy(space, " ");
- } else if (afford < 100000000) {
- strcpy(space, " ");
- } else {
- strcpy(space, "");
- }
- cputs(space);
- */
-
cprintulong(afford);
revers(0);
@@ -2962,6 +2954,9 @@ void bignum_test(void) {
for(i = 0; i < 14; i++) {
cprintfancy_big(n);
+ cputc(' ');
+ big_negate(n, n);
+ cprintfancy_big(n);
cputs("\r\n");
big_mul(n, n, o);
}