diff options
author | Dan Everton <dan@iocaine.org> | 2007-04-08 11:22:12 +0000 |
---|---|---|
committer | Dan Everton <dan@iocaine.org> | 2007-04-08 11:22:12 +0000 |
commit | 1322ae02f9ba77bbe6abff872593f051c4e6d1b5 (patch) | |
tree | 260c49c69c495152e289bf07014e5a85a3e4146a /apps/plugins | |
parent | 9e95e306cd6f17bc8f22d71608a21d47064b21eb (diff) |
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
Diffstat (limited to 'apps/plugins')
-rw-r--r-- | apps/plugins/calculator.c | 19 |
1 files changed, 17 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; |