Uploaded image for project: 'Drools'
  1. Drools
  2. DROOLS-314

Build in accumulate functions are highly unreliable for long's and BigDecimals

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Critical
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When dealing with financial data, one should never ever use double's. Instead BigDecimal should be used.
      Not because BigDecimal is bigger (that's rarely a problem) but because it doesn't do any decimal to binary transformation.
      For example, it's impossible for a double to correctly represent "0.2", aka 1/5.
      Summing many doubles (or even a few differing in scale), can easily give wrong results (and for financial data this tends to be important).

      Using doubles to sum longs have the exact same problem.
      Attached is a testcase patch which proves this by checking if (MAX_LONG - 4L) and 3L sum up to be (MAX_LONG - 1L).
      Currently they don't.

      One possible way to solve this is to fix JBRULES-1075,
      which just happens to give drools-solver 3% more performance what a coincidence ^^

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  tirelli Edson Tirelli
                  Reporter:
                  ge0ffrey Geoffrey De Smet
                • Votes:
                  2 Vote for this issue
                  Watchers:
                  5 Start watching this issue

                  Dates

                  • Created:
                    Updated: