Bug 71278 - tangent of 90 is possible
Summary: tangent of 90 is possible
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: Evan Teran
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-12-27 00:14 UTC by _
Modified: 2004-04-07 23:22 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description _ 2003-12-27 00:14:00 UTC
Version:           1.3.2 (using KDE 3.1.4)
Installed from:    SuSE
Compiler:          gcc version 3.3.1 (SuSE Linux)
OS:          Linux (i686) release 2.4.21-144-athlon

try calculating the tangent of 90 (tan(90))

its possible!
study maths and you know it isn't.
Comment 1 Albert Astals Cid 2004-02-19 18:54:23 UTC
CVS commit by aacid: 

Give error when trying to do a tangent of a number close enough to pi halves radians.
I'll backport in a moment.
CCMAIL:71278-done@bugs.kde.org


  M +9 -2      kcalc_core.cpp   1.84


--- kdeutils/kcalc/kcalc_core.cpp  #1.83:1.84
@@ -859,5 +859,5 @@ void CalcEngine::StatSumSquares(CALCAMNT
 void CalcEngine::Tangens(CALCAMNT input)
 {
-        CALCAMNT tmp = input;
+        CALCAMNT aux, tmp = input;
 
         switch (_angle_mode)
@@ -874,4 +874,11 @@ void CalcEngine::Tangens(CALCAMNT input)
         }
 
+        aux = tmp;
+        if (aux < 0) aux = -aux;
+        while (aux > pi) aux -= pi;
+        aux = aux - pi / 2;
+        if (aux < 1e-18L)
+                _error = true;
+        else
         _last_result = TAN(tmp);
 


Comment 2 Albert Astals Cid 2004-03-31 00:25:12 UTC
My fix introduced an even bigger bug so i have reverted the commit, these bug is still valid
Comment 3 Albert Astals Cid 2004-04-07 23:22:43 UTC
CVS commit by aacid: 

Fix #71278 again (without an associated bug)
CCMAIL:71278-done@bugs.kde.org


  M +15 -4     kcalc_core.cpp   1.86


--- kdeutils/kcalc/kcalc_core.cpp  #1.85:1.86
@@ -859,5 +859,5 @@ void CalcEngine::StatSumSquares(CALCAMNT
 void CalcEngine::Tangens(CALCAMNT input)
 {
-        CALCAMNT tmp = input;
+        CALCAMNT aux, tmp = input;
 
         switch (_angle_mode)
@@ -874,7 +874,18 @@ void CalcEngine::Tangens(CALCAMNT input)
         }
 
+        aux = tmp;
+        // make aux positive
+        if (aux < 0) aux = -aux;
+        // put aux between 0 and pi
+        while (aux > pi) aux -= pi;
+        // if were are really close to pi/2 throw an error
+        // tan(pi/2) => inf
+        // using the 10 factor because without it 270