Bug 276568 - kcalc miscalculates tan(0) = ∞ and freezes on cos(0)/0
Summary: kcalc miscalculates tan(0) = ∞ and freezes on cos(0)/0
Status: RESOLVED FIXED
Alias: None
Product: kcalc
Classification: Applications
Component: general (show other bugs)
Version: 2.8
Platform: Gentoo Packages Linux
: NOR crash with 20 votes (vote)
Target Milestone: ---
Assignee: Evan Teran
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-26 19:42 UTC by Cyp
Modified: 2011-07-06 18:17 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 Cyp 2011-06-26 19:42:56 UTC
Version:           2.8 (using KDE 4.6.3) 
OS:                Linux

kcalc miscalculates tan(0) = ∞ instead of 0.
kcalc miscalculates sin(0)/1.23 = ∞ instead of 0.
kcalc calculates 1/0 = ∞.
kcalc miscalculates cos(0)/0 = hang at 100% cpu instead of ∞.
kcalc miscalculates ln(2)/0 = hang at 100% cpu instead of ∞.


Reproducible: Always

Steps to Reproduce:
0t
0s/1.23
1/0
0c/0
2n/0

Actual Results:  
inf
inf
inf
hang at 100% cpu
hang at 100% cpu


Expected Results:  
0
0
inf
inf
inf
Comment 1 Christoph Feck 2011-06-26 23:00:50 UTC
Cannot reproduce. You probably have a buggy or incompatible version of libm or libgmp. My results are what you listed at "Expected" (and what I expected myself).
Comment 2 Cyp 2011-06-27 08:17:31 UTC
My libm and libgmp versions were:

sys-libs/glibc-2.12.2
dev-libs/gmp-4.3.2

Upgrading to dev-libs/gmp-5.0.2 and reinstalling kde-base/kcalc-4.6.3 didn't help.
Comment 3 Evan Teran 2011-06-28 15:29:22 UTC
The only one I can reproduce is:

"kcalc miscalculates ln(2)/0 = hang at 100% cpu instead of ∞."

This one definitely does hang for me, the rest appear to give expected results. I'll see if I can come up with a patch for it.
Comment 4 Evan Teran 2011-06-28 15:57:47 UTC
I've committed a fix for this issue. Which should appear in the KDE 4.7 release as far as I know.
Comment 5 Christoph Feck 2011-06-28 21:16:16 UTC
Evan, if you committed to trunk, it will appear in KDE 4.8. Please use the BUG: or CCBUG: keyword on commits so that others can follow your changes.
Comment 6 Evan Teran 2011-06-30 19:01:05 UTC
trunk is already pointed at 4.8? fair enough, I'll "backport" to 4.7/4.6.

I thought I did use BUG: xxxx, but I'll make sure I definitely do that in the future.
Comment 7 Evan Teran 2011-07-06 18:17:15 UTC
SVN commit 1240127 by teran:

backport of fix

BUG: 276568 


 U             knumber.cpp  
 M  +9 -2      knumber_priv.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1240127
Comment 8 Evan Teran 2011-07-06 18:17:30 UTC
SVN commit 1240128 by teran:

backport of fix       

BUG: 276568


 U             knumber.cpp  
 M  +11 -4     knumber_priv.cpp  


WebSVN link: http://websvn.kde.org/?view=rev&revision=1240128