Bug 211052

Summary: Too many decimal digits shown, showing floating point errors
Product: [Plasma] krunner Reporter: Marco Poletti <poletti.marco>
Component: generalAssignee: Plasma Bugs List <plasma-bugs>
Status: RESOLVED DUPLICATE    
Severity: normal    
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Unspecified   
Latest Commit: Version Fixed In:
Sentry Crash Report:

Description Marco Poletti 2009-10-19 09:40:16 UTC
Version:            (using KDE 4.3.1)
Installed from:    SuSE RPMs

Floating-point calculation always have some slight error caused by the precision of the binary representation of the number.
KRunner shows too much decimal digits, thus showing to the user these slight errors.
I think 6 decimal places or so are sufficient, allowing enough precision for most application and hiding small internal errors.
If you really want to keep this number of decimal places, you should use a higher-precision floating-point type, like «long double» instead of «double» or so.

Steps to reproduce:

Enter 190.12 - 186.69 =

Expected result:

= 3.43

Actual result:

= 3.430000000000007
Comment 1 Marco Poletti 2009-12-07 16:25:50 UTC
Still an issue in 4.4 beta 1.
Comment 2 Pino Toscano 2009-12-27 00:46:11 UTC

*** This bug has been marked as a duplicate of bug 167986 ***