Class DefaultNumberSystem

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Number abs​(Number number)
      Returns the absolute of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number add​(Number x, Number y)
      Returns the sum of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      int compare​(Number x, Number y)
      Compares two Number values numerically.
      Number divide​(Number x, Number y)
      Returns the division of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number[] divideAndRemainder​(Number x, Number y, boolean roundRemainderTowardsZero)
      Returns a two-element Number array containing {x / y, x % y}
      Number exp​(Number number)
      Returns Euler's Constant to the power of of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      boolean isInteger​(Number number)
      Checks whether given number has fractional parts or not.
      boolean isLessThanOne​(Number number)  
      boolean isOne​(Number number)  
      boolean isZero​(Number number)  
      Number log​(Number number)
      Returns the natural logarithm of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number multiply​(Number x, Number y)
      Returns the product of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number narrow​(Number number)
      'Narrows' given number as a Number that best represents the numeric value within the set of number types this NumberSystem supports.
      Number negate​(Number number)
      Returns the negation of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number power​(Number number, int exponent)
      Returns given number to the power of exponent as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      Number reciprocal​(Number number)
      Returns the reciprocal of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
      int signum​(Number number)
      Returns the signum function of given number.
      Number subtract​(Number x, Number y)
      Returns the difference of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
    • Method Detail

      • add

        public Number add​(Number x,
                          Number y)
        Description copied from interface: NumberSystem
        Returns the sum of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        add in interface NumberSystem
        Returns:
        x + y
      • subtract

        public Number subtract​(Number x,
                               Number y)
        Description copied from interface: NumberSystem
        Returns the difference of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        subtract in interface NumberSystem
        Returns:
        x - y
      • multiply

        public Number multiply​(Number x,
                               Number y)
        Description copied from interface: NumberSystem
        Returns the product of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        multiply in interface NumberSystem
        Returns:
        x * y
      • divide

        public Number divide​(Number x,
                             Number y)
        Description copied from interface: NumberSystem
        Returns the division of given x and y as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        divide in interface NumberSystem
        Returns:
        x / y
      • divideAndRemainder

        public Number[] divideAndRemainder​(Number x,
                                           Number y,
                                           boolean roundRemainderTowardsZero)
        Description copied from interface: NumberSystem
        Returns a two-element Number array containing {x / y, x % y}
        Specified by:
        divideAndRemainder in interface NumberSystem
        roundRemainderTowardsZero - - whether the division remainder should be rounded towards zero
        Returns:
      • reciprocal

        public Number reciprocal​(Number number)
        Description copied from interface: NumberSystem
        Returns the reciprocal of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        reciprocal in interface NumberSystem
        Returns:
        number^-1
      • signum

        public int signum​(Number number)
        Description copied from interface: NumberSystem
        Returns the signum function of given number.
        Specified by:
        signum in interface NumberSystem
        Returns:
        signum(number)
      • abs

        public Number abs​(Number number)
        Description copied from interface: NumberSystem
        Returns the absolute of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        abs in interface NumberSystem
        Returns:
        abs(number)
      • negate

        public Number negate​(Number number)
        Description copied from interface: NumberSystem
        Returns the negation of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        negate in interface NumberSystem
        Returns:
        -number
      • power

        public Number power​(Number number,
                            int exponent)
        Description copied from interface: NumberSystem
        Returns given number to the power of exponent as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        power in interface NumberSystem
        exponent - - an integer
        Returns:
        number^exponent
      • exp

        public Number exp​(Number number)
        Description copied from interface: NumberSystem
        Returns Euler's Constant to the power of of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        exp in interface NumberSystem
        Returns:
        e^number, with e Euler's Constant)
      • log

        public Number log​(Number number)
        Description copied from interface: NumberSystem
        Returns the natural logarithm of given number as a Number that best represents the arithmetic result within the set of number types this NumberSystem supports.
        Specified by:
        log in interface NumberSystem
        Returns:
        natural logarithm of number
      • narrow

        public Number narrow​(Number number)
        Description copied from interface: NumberSystem
        'Narrows' given number as a Number that best represents the numeric value within the set of number types this NumberSystem supports.

        eg. A BigInteger that is within range of Java's Long type can be narrowed to Long w/o loss of precision.

        Specified by:
        narrow in interface NumberSystem
        Returns:
        'best' representation of number w/o loss of precision
      • compare

        public int compare​(Number x,
                           Number y)
        Description copied from interface: NumberSystem
        Compares two Number values numerically.
        Specified by:
        compare in interface NumberSystem
        Returns:
        the value 0 if x == y; a value less than 0 if x < y; and a value greater than 0 if x > y
      • isInteger

        public boolean isInteger​(Number number)
        Description copied from interface: NumberSystem
        Checks whether given number has fractional parts or not.
        Specified by:
        isInteger in interface NumberSystem
        Returns:
        whether number represents a whole number