use global Buf everywhere for debugging

This commit is contained in:
Jeff Wang 2019-03-28 00:41:54 -04:00
parent 91b7b82462
commit bdecc32b86
3 changed files with 46 additions and 46 deletions

View File

@ -457,7 +457,7 @@ static void sub_mag(dec80* acc, const dec80* x){
_incr_exp(&tmp, get_exponent(acc));
}
#ifdef DEBUG_ADD
extern char buf[DECN_BUF_SIZE];
extern char Buf[DECN_BUF_SIZE];
dec80_to_str(buf, &tmp);
printf(" incr_exp tmp: %s\n", buf);
#endif
@ -546,7 +546,7 @@ void add_decn(dec80* acc, const dec80* x){
remove_leading_zeros(acc);
remove_leading_zeros(&tmp);
#ifdef DEBUG_ADD
extern char buf[DECN_BUF_SIZE];
extern char Buf[DECN_BUF_SIZE];
dec80_to_str(buf, acc);
printf(" rem_leading_zeros acc: %s\n", buf);
dec80_to_str(buf, &tmp);
@ -562,7 +562,7 @@ void add_decn(dec80* acc, const dec80* x){
set_exponent(acc, get_exponent(&tmp), (acc->exponent < 0));
}
#ifdef DEBUG_ADD
extern char buf[DECN_BUF_SIZE];
extern char Buf[DECN_BUF_SIZE];
dec80_to_str(buf, acc);
printf(" incr_exp acc: %s\n", buf);
dec80_to_str(buf, &tmp);
@ -701,7 +701,7 @@ void div_decn(dec80* acc, const dec80* x){
//do newton raphson iterations
for (i = 0; i < 20; i++){ //just fix number of iterations for now
#ifdef DEBUG_DIV
char buf[80];
extern char Buf[80];
dec80_to_str(buf, &tmp);
printf("%2d: %s\n", i, buf);
#endif

View File

@ -7,94 +7,94 @@
#include <stdio.h>
#include "decn.h"
char buf[DECN_BUF_SIZE];
char Buf[DECN_BUF_SIZE];
int main(void){
dec80 acc, b;
build_dec80(&acc, "0.0009234567890123456", 7);
dec80_to_str(buf, &acc);
printf(" acc: %s\n", buf);
dec80_to_str(Buf, &acc);
printf(" acc: %s\n", Buf);
build_dec80(&acc, "9.234567890123456", 3);
dec80_to_str(buf, &acc);
printf(" acc: %s\n", buf);
dec80_to_str(Buf, &acc);
printf(" acc: %s\n", Buf);
negate_decn(&acc);
dec80_to_str(buf, &acc);
printf("-acc: %s\n", buf);
dec80_to_str(Buf, &acc);
printf("-acc: %s\n", Buf);
build_dec80(&b, "-92.3456789012345678", 1);
dec80_to_str(buf, &b);
printf(" b: %s\n", buf);
dec80_to_str(Buf, &b);
printf(" b: %s\n", Buf);
dec80_to_str(buf, &acc);
printf("-acc: %s\n", buf);
dec80_to_str(Buf, &acc);
printf("-acc: %s\n", Buf);
//compare result of b - acc
add_decn(&acc, &b);
dec80_to_str(buf, &acc);
printf("\nb - a: %s", buf);
dec80_to_str(Buf, &acc);
printf("\nb - a: %s", Buf);
printf("\n : %s", "-10158.0246791358016");
dec80 diff;
build_dec80(&diff, "-1.01580246791358016", 4);
negate_decn(&diff);
add_decn(&diff, &acc);
dec80_to_str(buf, &diff);
printf("\n : %s\n\n", buf);
dec80_to_str(Buf, &diff);
printf("\n : %s\n\n", Buf);
//new acc for acc - b test
dec80_to_str(buf, &acc);
printf("acc: %s\n", buf);
dec80_to_str(Buf, &acc);
printf("acc: %s\n", Buf);
negate_decn(&b);
dec80_to_str(buf, &b);
printf(" -b: %s\n", buf);
dec80_to_str(Buf, &b);
printf(" -b: %s\n", Buf);
add_decn(&acc, &b);
dec80_to_str(buf, &acc);
dec80_to_str(Buf, &acc);
//compare result of new acc - b
printf("acc - b: %s\n", buf);
printf("acc - b: %s\n", Buf);
printf(" : %s\n", "-9234.567890123456");
build_dec80(&diff, "-9.234567890123456", 3);
negate_decn(&diff);
add_decn(&diff, &acc);
dec80_to_str(buf, &diff);
printf(" : %s\n\n", buf);
dec80_to_str(Buf, &diff);
printf(" : %s\n\n", Buf);
//new acc and b for multiply test
// build_dec80(&acc, "7", 2);
build_dec80(&acc, "92.34567890123456", 2);
build_dec80(&b, "-92.3456789012345678", 1);
dec80_to_str(buf, &acc);
printf(" acc: %s\n", buf);
dec80_to_str(buf, &b);
printf(" b: %s\n", buf);
dec80_to_str(Buf, &acc);
printf(" acc: %s\n", Buf);
dec80_to_str(Buf, &b);
printf(" b: %s\n", Buf);
mult_decn(&acc, &b);
dec80_to_str(buf, &acc);
printf("acc*b: %s\n", buf);
dec80_to_str(Buf, &acc);
printf("acc*b: %s\n", Buf);
printf(" : %s\n", "-8527724.41172991849");
build_dec80(&diff, "-8.52772441172991849", 6);
negate_decn(&diff);
add_decn(&diff, &acc);
dec80_to_str(buf, &diff);
printf(" : %s\n\n", buf);
dec80_to_str(Buf, &diff);
printf(" : %s\n\n", Buf);
//new acc and b for divide test
build_dec80(&acc, "3.14", 88);
build_dec80(&b, "-1.5", -2);
dec80_to_str(buf, &acc);
printf(" acc: %s\n", buf);
dec80_to_str(buf, &b);
printf(" b: %s\n", buf);
dec80_to_str(Buf, &acc);
printf(" acc: %s\n", Buf);
dec80_to_str(Buf, &b);
printf(" b: %s\n", Buf);
div_decn(&acc, &b);
dec80_to_str(buf, &acc);
printf("acc/b: %s\n", buf);
dec80_to_str(Buf, &acc);
printf("acc/b: %s\n", Buf);
printf(" : %s\n", "-2.09333333333333334E90");
build_dec80(&diff, "-2.09333333333333334", 90);
negate_decn(&diff);
add_decn(&diff, &acc);
dec80_to_str(buf, &diff);
printf(" : %s\n\n", buf);
dec80_to_str(Buf, &diff);
printf(" : %s\n\n", Buf);
return 0;

View File

@ -81,7 +81,7 @@ void Timer0Init(void)
}
char buf[17];
char Buf[17];
/*********************************************/
int main()
@ -122,9 +122,9 @@ int main()
LCD_OutString(" ");
} else if (SecCount < 10){
TERMIO_PutChar(' ');
LCD_OutString(u32str(SecCount, buf, 10));
LCD_OutString(u32str(SecCount, Buf, 10));
} else {
LCD_OutString(u32str(SecCount, buf, 10));
LCD_OutString(u32str(SecCount, Buf, 10));
}
///new keys