From 1322ae02f9ba77bbe6abff872593f051c4e6d1b5 Mon Sep 17 00:00:00 2001 From: Dan Everton Date: Sun, 8 Apr 2007 11:22:12 +0000 Subject: [PATCH] FS #6759: Support tan function in calculator plugin. Patch by Luke Blaney. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@13070 a1c6a512-1295-4272-9138-f99709370657 --- apps/plugins/calculator.c | 19 +++++++++++++++++-- docs/CREDITS | 1 + 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/plugins/calculator.c b/apps/plugins/calculator.c index 05f9c73ba9..775210d7f3 100644 --- a/apps/plugins/calculator.c +++ b/apps/plugins/calculator.c @@ -521,7 +521,7 @@ void transcendFunc(char* func, double* tt, int* ttPower) *ttPower = 0; calStatus = cal_normal; - if( func[0] =='s' || func[0] =='S') + if( func[0] =='s' || func[0] =='S'|| func[0] =='t' || func[0] =='T') sign = SIGN(t); else { /* if( func[0] =='c' || func[0] =='C') */ @@ -544,6 +544,8 @@ void transcendFunc(char* func, double* tt, int* ttPower) t = M_PI - t; if (func[0] =='c' || func[0] =='C') sign = -1; + else if (func[0] =='t' || func[0] =='T') + t*=-1; } else if ( 3*M_PI_2 <= t && t <= M_TWOPI) t -= M_TWOPI; @@ -561,10 +563,20 @@ void transcendFunc(char* func, double* tt, int* ttPower) *tt = sign*y; return; } - else /* if( func[0] =='c' || func[0] =='C')*/ { + else if( func[0] =='c' || func[0] =='C') { *tt = sign*x; return; } + else /*if( func[0] =='t' || func[0] =='T')*/ { + if(t==M_PI_2||t==-M_PI_2){ + calStatus = cal_error; + return; + } + else{ + *tt = sign*(y/x); + return; + } + } } /* ----------------------------------------------------------------------- @@ -658,6 +670,9 @@ void oneOperand(void) case sci_cos: transcendFunc("cos", &result, &power); break; + case sci_tan: + transcendFunc("tan", &result, &power); + break; case sci_fac: if (power<0 || power>8 || result<0 ) calStatus = cal_error; diff --git a/docs/CREDITS b/docs/CREDITS index da13cc6723..95ee473680 100644 --- a/docs/CREDITS +++ b/docs/CREDITS @@ -287,3 +287,4 @@ Jacob Gardner Pascal Briehl Denis Stanishevskiy Eddy Coman +Luke Blaney