java.lang.Object
org.apache.commons.statistics.descriptive.UInt96

final class UInt96 extends Object
A mutable 96-bit unsigned integer.

This is a specialised class to implement an accumulator of long values generated by squaring int values from an array (max observations=2^31).

Since:
1.1
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private long
    bits 96-33.
    private int
    bits 32-1 (low 32-bits).
    private static final long
    Mask for the lower 32-bits of a long.
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    private
    Create an instance.
    private
    UInt96(long x)
    Create an instance.
    (package private)
    UInt96(long hi, int lo)
    Create an instance using a direct binary representation.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) void
    Adds the value.
    (package private) void
    addPositive(long x)
    Adds the value.
    (package private) static UInt96
    Create an instance.
    (package private) long
    Return the higher 64-bits as a long value.
    (package private) int
    Return the lower 32-bits as an int value.
    (package private) static UInt96
    of(long x)
    Create an instance of the long value.
    (package private) BigInteger
    Convert to a BigInteger.

    Methods inherited from class java.lang.Object

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

    • MASK32

      private static final long MASK32
      Mask for the lower 32-bits of a long.
      See Also:
    • c

      private int c
      bits 32-1 (low 32-bits).
    • ab

      private long ab
      bits 96-33.
  • Constructor Details

    • UInt96

      private UInt96()
      Create an instance.
    • UInt96

      private UInt96(long x)
      Create an instance.
      Parameters:
      x - Value.
    • UInt96

      UInt96(long hi, int lo)
      Create an instance using a direct binary representation. This is package-private for testing.
      Parameters:
      hi - High 64-bits.
      lo - Low 32-bits.
  • Method Details

    • create

      static UInt96 create()
      Create an instance. The initial value is zero.
      Returns:
      the instance
    • of

      static UInt96 of(long x)
      Create an instance of the long value. The value is assumed to be an unsigned 64-bit integer.
      Parameters:
      x - Value (must be positive).
      Returns:
      the instance
    • addPositive

      void addPositive(long x)
      Adds the value. It is assumed to be positive, for example the square of an int value. However no check is performed for a negative value.

      Note: This addition handles -9223372036854775808L as an unsigned value of 2^63.

      Parameters:
      x - Value.
    • add

      void add(UInt96 x)
      Adds the value.
      Parameters:
      x - Value.
    • toBigInteger

      BigInteger toBigInteger()
      Convert to a BigInteger.
      Returns:
      the value
    • lo32

      int lo32()
      Return the lower 32-bits as an int value.
      Returns:
      bits 32-1
    • hi64

      long hi64()
      Return the higher 64-bits as a long value.
      Returns:
      bits 96-33