Skip to content

Commit

Permalink
bug fix for Factorial function
Browse files Browse the repository at this point in the history
bug fix for Factorial function
  • Loading branch information
Dave1975-spring authored Jan 4, 2025
1 parent f700ec0 commit 7cfdece
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions RPNV.C
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@
#include <string.h>
#include <i86.h>

#define VERSION "0.7.3"
#define VERSION "0.7.4"
#define offset_col 7
#define offset_row 8
#define pitch_col 7
#define pitch_row 4
#define M_PI 3.14159265359
#define MAXDIGITS 12
#define A 12 // used in Spouge's approximation for Gamma function

#ifndef M_PI
#define M_PI 3.14159265359
#endif

double stack[4] = {0.0,0.0,0.0,0.0}; // stack>: X,Y,Z,T registers
double lastx = 0.0; // last x register
double memory[10] = {0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; // memory
Expand Down Expand Up @@ -1099,9 +1102,12 @@ void hit_button_at_curpos(int curpos)
}
else {
if (stackx_exp_hit==true) stackx_by_exp();
stack[0] = factorial(stack[0]);
func_hit = true;
second_f = false;
if (stack[0]>=0.0) {
if (stack[0]>0.0) stack[0] = factorial(stack[0]);
else stack[0]=1.0;
func_hit = true;
second_f = false;
} else print_message(6,"Negative number!");
}
update_lcd();
break;
Expand Down

0 comments on commit 7cfdece

Please sign in to comment.