Class Summarizer

java.lang.Object
application.model.rules.misc.Summarizer

class Summarizer
extends java.lang.Object
Adds up numbers in an array with perfect precision, and in O(n). From https://code.activestate.com/recipes/393090/
  • Constructor Summary

    Constructors 
    Constructor Description
    Summarizer()  
  • Method Summary

    Modifier and Type Method Description
    static double msum​(double... values)
    Perfectly sums up numbers, without rounding errors (if at all possible).
    static double msum​(java.util.Collection<java.lang.Double> values)
    Perfectly sums up numbers, without rounding errors (if at all possible).
    static double sum​(java.util.Collection<java.lang.Double> values)
    Sums up the rest of the partial numbers which cannot be summed up without loss of precision.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • msum

      public static double msum​(double... values)
      Perfectly sums up numbers, without rounding errors (if at all possible).
      Parameters:
      values - The values to sum up.
      Returns:
      The sum.
    • msum

      public static double msum​(java.util.Collection<java.lang.Double> values)
      Perfectly sums up numbers, without rounding errors (if at all possible).
      Parameters:
      values - The values to sum up.
      Returns:
      The sum.
    • sum

      public static double sum​(java.util.Collection<java.lang.Double> values)
      Sums up the rest of the partial numbers which cannot be summed up without loss of precision.