Issue 7410 - Wrong result on simple addition/subtraction
Summary: Wrong result on simple addition/subtraction
Status: CLOSED NOT_AN_OOO_ISSUE
Alias: None
Product: Calc
Classification: Application
Component: code (show other issues)
Version: OOo 1.0.0
Hardware: PC Windows 2000
: P1 (highest) Trivial (vote)
Target Milestone: ---
Assignee: ooo
QA Contact: issues@sc
URL:
Keywords:
: 41924 110570 (view as issue list)
Depends on:
Blocks:
 
Reported: 2002-09-01 09:36 UTC by Unknown
Modified: 2010-04-03 08:52 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Unknown 2002-09-01 09:36:38 UTC
Example:

A1: =13114.77
A2: =13401.55
A3: =A1-A2                             (shows -286.78)
A4: =IF(A3=-286.78;"OK";"WHAT?!?")     (shows WHAT?!?)

If the accuracy of A3 is increased (e.g to 20 digis after the decimal point), 
one can see that the subtraction result is something -286.7799999999000000. 
Note that the numbers in A1 and A2 have been entered by hand, without any 
hidden digits. Looks like a real bug therefore. 

PS: I do not have one of these original Pentium, but an Athlon Thunderbird.
Comment 1 frank 2002-11-28 14:36:57 UTC
For me it seems to be one of these Issues dealing with the calculating
capabilities of C++.

Assigned to Eike. He will have a look at it.

Workaround :
Set Precision as shown under Tools - Options - Spreadsheet - Calculate

Frank
Comment 2 ooo 2002-11-28 18:46:58 UTC
This is normal computer behavior with roundoff errors, and it has
nothing to do with C++ or any other computer language but binary
representation of floating point values instead. If you want to
compare floating point values you have to round them, so your
conditional statement should read
=IF(ROUND(A3;2)=-286.78;"OK";"WHAT?!?")
Comment 3 ooo 2002-11-28 18:47:20 UTC
closing
Comment 4 frank 2005-02-11 11:17:22 UTC
*** Issue 41924 has been marked as a duplicate of this issue. ***
Comment 5 Rainer Bielefeld 2010-04-03 08:52:15 UTC
*** Issue 110570 has been marked as a duplicate of this issue. ***