add log10() function
This commit is contained in:
parent
0f17fbdcc7
commit
21be4081b2
11
src/calc.c
11
src/calc.c
@ -118,12 +118,21 @@ void process_cmd(char cmd){
|
||||
toggle_shifted();
|
||||
} break;
|
||||
//////////
|
||||
case '9':{
|
||||
if (IsShifted && !decn_is_nan(&stack(STACK_X))){ //log10(x)
|
||||
copy_decn(&AccDecn, &stack(STACK_X));
|
||||
log10_decn();
|
||||
copy_decn(&stack(STACK_X), &AccDecn);
|
||||
IsShifted = 0;
|
||||
}
|
||||
} break;
|
||||
//////////
|
||||
case '8':{
|
||||
if (IsShifted && !decn_is_nan(&stack(STACK_X))){ //ln(x)
|
||||
copy_decn(&AccDecn, &stack(STACK_X));
|
||||
ln_decn();
|
||||
copy_decn(&stack(STACK_X), &AccDecn);
|
||||
toggle_shifted();
|
||||
IsShifted = 0;
|
||||
}
|
||||
} break;
|
||||
//////////
|
||||
|
@ -47,9 +47,9 @@ static const uint8_t num_digits_display = 16;
|
||||
|
||||
__idata dec80 AccDecn, BDecn;
|
||||
__idata dec80 TmpDecn; //used by add_decn() and mult_decn()
|
||||
__idata dec80 Tmp2Decn; //used by div_decn()
|
||||
__idata dec80 Tmp3Decn; //used by div_decn()
|
||||
__idata dec80 Tmp4Decn; //used by div_decn()
|
||||
__idata dec80 Tmp2Decn; //used by div_decn() and ln_decn()
|
||||
__idata dec80 Tmp3Decn; //used by div_decn() and ln_decn()
|
||||
__idata dec80 Tmp4Decn; //used by div_decn() and ln_decn()
|
||||
|
||||
__xdata char Buf[DECN_BUF_SIZE];
|
||||
|
||||
@ -1015,6 +1015,12 @@ void ln_decn(void){
|
||||
#undef NUM_A_ARR
|
||||
}
|
||||
|
||||
void log10_decn(void){
|
||||
ln_decn();
|
||||
copy_decn(&BDecn, &DECN_LN_10);
|
||||
div_decn();
|
||||
}
|
||||
|
||||
static void set_str_error(void){
|
||||
Buf[0] = 'E';
|
||||
Buf[1] = 'r';
|
||||
|
@ -69,6 +69,7 @@ void mult_decn(void);
|
||||
void div_decn(void);
|
||||
|
||||
void ln_decn(void);
|
||||
void log10_decn(void);
|
||||
|
||||
//Buf should hold at least 18 + 4 + 5 + 1 = 28
|
||||
#define DECN_BUF_SIZE 28
|
||||
|
Loading…
Reference in New Issue
Block a user