summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Everton <dan@iocaine.org>2007-04-08 11:22:12 +0000
committerDan Everton <dan@iocaine.org>2007-04-08 11:22:12 +0000
commit1322ae02f9ba77bbe6abff872593f051c4e6d1b5 (patch)
tree260c49c69c495152e289bf07014e5a85a3e4146a
parent9e95e306cd6f17bc8f22d71608a21d47064b21eb (diff)
downloadrockbox-1322ae02f9ba77bbe6abff872593f051c4e6d1b5.tar.gz
rockbox-1322ae02f9ba77bbe6abff872593f051c4e6d1b5.zip
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
-rw-r--r--apps/plugins/calculator.c19
-rw-r--r--docs/CREDITS1
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