use global Buf everywhere for debugging
This commit is contained in:
parent
91b7b82462
commit
bdecc32b86
@ -457,7 +457,7 @@ static void sub_mag(dec80* acc, const dec80* x){
|
|||||||
_incr_exp(&tmp, get_exponent(acc));
|
_incr_exp(&tmp, get_exponent(acc));
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ADD
|
#ifdef DEBUG_ADD
|
||||||
extern char buf[DECN_BUF_SIZE];
|
extern char Buf[DECN_BUF_SIZE];
|
||||||
dec80_to_str(buf, &tmp);
|
dec80_to_str(buf, &tmp);
|
||||||
printf(" incr_exp tmp: %s\n", buf);
|
printf(" incr_exp tmp: %s\n", buf);
|
||||||
#endif
|
#endif
|
||||||
@ -546,7 +546,7 @@ void add_decn(dec80* acc, const dec80* x){
|
|||||||
remove_leading_zeros(acc);
|
remove_leading_zeros(acc);
|
||||||
remove_leading_zeros(&tmp);
|
remove_leading_zeros(&tmp);
|
||||||
#ifdef DEBUG_ADD
|
#ifdef DEBUG_ADD
|
||||||
extern char buf[DECN_BUF_SIZE];
|
extern char Buf[DECN_BUF_SIZE];
|
||||||
dec80_to_str(buf, acc);
|
dec80_to_str(buf, acc);
|
||||||
printf(" rem_leading_zeros acc: %s\n", buf);
|
printf(" rem_leading_zeros acc: %s\n", buf);
|
||||||
dec80_to_str(buf, &tmp);
|
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));
|
set_exponent(acc, get_exponent(&tmp), (acc->exponent < 0));
|
||||||
}
|
}
|
||||||
#ifdef DEBUG_ADD
|
#ifdef DEBUG_ADD
|
||||||
extern char buf[DECN_BUF_SIZE];
|
extern char Buf[DECN_BUF_SIZE];
|
||||||
dec80_to_str(buf, acc);
|
dec80_to_str(buf, acc);
|
||||||
printf(" incr_exp acc: %s\n", buf);
|
printf(" incr_exp acc: %s\n", buf);
|
||||||
dec80_to_str(buf, &tmp);
|
dec80_to_str(buf, &tmp);
|
||||||
@ -701,7 +701,7 @@ void div_decn(dec80* acc, const dec80* x){
|
|||||||
//do newton raphson iterations
|
//do newton raphson iterations
|
||||||
for (i = 0; i < 20; i++){ //just fix number of iterations for now
|
for (i = 0; i < 20; i++){ //just fix number of iterations for now
|
||||||
#ifdef DEBUG_DIV
|
#ifdef DEBUG_DIV
|
||||||
char buf[80];
|
extern char Buf[80];
|
||||||
dec80_to_str(buf, &tmp);
|
dec80_to_str(buf, &tmp);
|
||||||
printf("%2d: %s\n", i, buf);
|
printf("%2d: %s\n", i, buf);
|
||||||
#endif
|
#endif
|
||||||
|
@ -7,94 +7,94 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "decn.h"
|
#include "decn.h"
|
||||||
|
|
||||||
char buf[DECN_BUF_SIZE];
|
char Buf[DECN_BUF_SIZE];
|
||||||
|
|
||||||
int main(void){
|
int main(void){
|
||||||
dec80 acc, b;
|
dec80 acc, b;
|
||||||
|
|
||||||
build_dec80(&acc, "0.0009234567890123456", 7);
|
build_dec80(&acc, "0.0009234567890123456", 7);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf(" acc: %s\n", buf);
|
printf(" acc: %s\n", Buf);
|
||||||
|
|
||||||
build_dec80(&acc, "9.234567890123456", 3);
|
build_dec80(&acc, "9.234567890123456", 3);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf(" acc: %s\n", buf);
|
printf(" acc: %s\n", Buf);
|
||||||
|
|
||||||
negate_decn(&acc);
|
negate_decn(&acc);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("-acc: %s\n", buf);
|
printf("-acc: %s\n", Buf);
|
||||||
|
|
||||||
build_dec80(&b, "-92.3456789012345678", 1);
|
build_dec80(&b, "-92.3456789012345678", 1);
|
||||||
dec80_to_str(buf, &b);
|
dec80_to_str(Buf, &b);
|
||||||
printf(" b: %s\n", buf);
|
printf(" b: %s\n", Buf);
|
||||||
|
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("-acc: %s\n", buf);
|
printf("-acc: %s\n", Buf);
|
||||||
|
|
||||||
//compare result of b - acc
|
//compare result of b - acc
|
||||||
add_decn(&acc, &b);
|
add_decn(&acc, &b);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("\nb - a: %s", buf);
|
printf("\nb - a: %s", Buf);
|
||||||
printf("\n : %s", "-10158.0246791358016");
|
printf("\n : %s", "-10158.0246791358016");
|
||||||
dec80 diff;
|
dec80 diff;
|
||||||
build_dec80(&diff, "-1.01580246791358016", 4);
|
build_dec80(&diff, "-1.01580246791358016", 4);
|
||||||
negate_decn(&diff);
|
negate_decn(&diff);
|
||||||
add_decn(&diff, &acc);
|
add_decn(&diff, &acc);
|
||||||
dec80_to_str(buf, &diff);
|
dec80_to_str(Buf, &diff);
|
||||||
printf("\n : %s\n\n", buf);
|
printf("\n : %s\n\n", Buf);
|
||||||
|
|
||||||
//new acc for acc - b test
|
//new acc for acc - b test
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("acc: %s\n", buf);
|
printf("acc: %s\n", Buf);
|
||||||
negate_decn(&b);
|
negate_decn(&b);
|
||||||
dec80_to_str(buf, &b);
|
dec80_to_str(Buf, &b);
|
||||||
printf(" -b: %s\n", buf);
|
printf(" -b: %s\n", Buf);
|
||||||
|
|
||||||
add_decn(&acc, &b);
|
add_decn(&acc, &b);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
//compare result of new acc - b
|
//compare result of new acc - b
|
||||||
printf("acc - b: %s\n", buf);
|
printf("acc - b: %s\n", Buf);
|
||||||
printf(" : %s\n", "-9234.567890123456");
|
printf(" : %s\n", "-9234.567890123456");
|
||||||
build_dec80(&diff, "-9.234567890123456", 3);
|
build_dec80(&diff, "-9.234567890123456", 3);
|
||||||
negate_decn(&diff);
|
negate_decn(&diff);
|
||||||
add_decn(&diff, &acc);
|
add_decn(&diff, &acc);
|
||||||
dec80_to_str(buf, &diff);
|
dec80_to_str(Buf, &diff);
|
||||||
printf(" : %s\n\n", buf);
|
printf(" : %s\n\n", Buf);
|
||||||
|
|
||||||
//new acc and b for multiply test
|
//new acc and b for multiply test
|
||||||
// build_dec80(&acc, "7", 2);
|
// build_dec80(&acc, "7", 2);
|
||||||
build_dec80(&acc, "92.34567890123456", 2);
|
build_dec80(&acc, "92.34567890123456", 2);
|
||||||
build_dec80(&b, "-92.3456789012345678", 1);
|
build_dec80(&b, "-92.3456789012345678", 1);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf(" acc: %s\n", buf);
|
printf(" acc: %s\n", Buf);
|
||||||
dec80_to_str(buf, &b);
|
dec80_to_str(Buf, &b);
|
||||||
printf(" b: %s\n", buf);
|
printf(" b: %s\n", Buf);
|
||||||
mult_decn(&acc, &b);
|
mult_decn(&acc, &b);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("acc*b: %s\n", buf);
|
printf("acc*b: %s\n", Buf);
|
||||||
printf(" : %s\n", "-8527724.41172991849");
|
printf(" : %s\n", "-8527724.41172991849");
|
||||||
build_dec80(&diff, "-8.52772441172991849", 6);
|
build_dec80(&diff, "-8.52772441172991849", 6);
|
||||||
negate_decn(&diff);
|
negate_decn(&diff);
|
||||||
add_decn(&diff, &acc);
|
add_decn(&diff, &acc);
|
||||||
dec80_to_str(buf, &diff);
|
dec80_to_str(Buf, &diff);
|
||||||
printf(" : %s\n\n", buf);
|
printf(" : %s\n\n", Buf);
|
||||||
|
|
||||||
//new acc and b for divide test
|
//new acc and b for divide test
|
||||||
build_dec80(&acc, "3.14", 88);
|
build_dec80(&acc, "3.14", 88);
|
||||||
build_dec80(&b, "-1.5", -2);
|
build_dec80(&b, "-1.5", -2);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf(" acc: %s\n", buf);
|
printf(" acc: %s\n", Buf);
|
||||||
dec80_to_str(buf, &b);
|
dec80_to_str(Buf, &b);
|
||||||
printf(" b: %s\n", buf);
|
printf(" b: %s\n", Buf);
|
||||||
div_decn(&acc, &b);
|
div_decn(&acc, &b);
|
||||||
dec80_to_str(buf, &acc);
|
dec80_to_str(Buf, &acc);
|
||||||
printf("acc/b: %s\n", buf);
|
printf("acc/b: %s\n", Buf);
|
||||||
printf(" : %s\n", "-2.09333333333333334E90");
|
printf(" : %s\n", "-2.09333333333333334E90");
|
||||||
build_dec80(&diff, "-2.09333333333333334", 90);
|
build_dec80(&diff, "-2.09333333333333334", 90);
|
||||||
negate_decn(&diff);
|
negate_decn(&diff);
|
||||||
add_decn(&diff, &acc);
|
add_decn(&diff, &acc);
|
||||||
dec80_to_str(buf, &diff);
|
dec80_to_str(Buf, &diff);
|
||||||
printf(" : %s\n\n", buf);
|
printf(" : %s\n\n", Buf);
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -81,7 +81,7 @@ void Timer0Init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char buf[17];
|
char Buf[17];
|
||||||
|
|
||||||
/*********************************************/
|
/*********************************************/
|
||||||
int main()
|
int main()
|
||||||
@ -122,9 +122,9 @@ int main()
|
|||||||
LCD_OutString(" ");
|
LCD_OutString(" ");
|
||||||
} else if (SecCount < 10){
|
} else if (SecCount < 10){
|
||||||
TERMIO_PutChar(' ');
|
TERMIO_PutChar(' ');
|
||||||
LCD_OutString(u32str(SecCount, buf, 10));
|
LCD_OutString(u32str(SecCount, Buf, 10));
|
||||||
} else {
|
} else {
|
||||||
LCD_OutString(u32str(SecCount, buf, 10));
|
LCD_OutString(u32str(SecCount, Buf, 10));
|
||||||
}
|
}
|
||||||
|
|
||||||
///new keys
|
///new keys
|
||||||
|
Loading…
Reference in New Issue
Block a user