Summary: | tangent of 90 is possible | ||
---|---|---|---|
Product: | [Applications] kcalc | Reporter: | _ <praseodym+kdebugzilla> |
Component: | general | Assignee: | Evan Teran <eteran> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | aacid |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | openSUSE | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: |
Description
_
2003-12-27 00:14:00 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); My fix introduced an even bigger bug so i have reverted the commit, these bug is still valid 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 |