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.
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