Class BigSignificand


  • final class BigSignificand
    extends java.lang.Object
    A mutable non-negative significand with a fixed number of bits.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private int firstNonZeroInt  
      private static long LONG_MASK  
      private int numInts  
      private static java.lang.invoke.VarHandle readIntBE  
      private byte[] x  
    • Constructor Summary

      Constructors 
      Constructor Description
      BigSignificand​(long numBits)
      Creates a new instance with the specified number in bits.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(int value)
      Adds the specified value to the significand in place.
      void fma​(int factor, int addend)
      Multiplies the significand with the specified factor in place, and then adds the specified addend to it (also in place).
      java.math.BigInteger toBigInteger()
      Converts the BigSignificand to a BigInteger.
      private int x​(int i)  
      private void x​(int i, int value)  
      • Methods inherited from class java.lang.Object

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

      • readIntBE

        private static final java.lang.invoke.VarHandle readIntBE
      • numInts

        private final int numInts
      • x

        private final byte[] x
      • firstNonZeroInt

        private int firstNonZeroInt
    • Constructor Detail

      • BigSignificand

        public BigSignificand​(long numBits)
        Creates a new instance with the specified number in bits.
        Parameters:
        numBits - the number of bits in range [0, Integer.MAX_VALUE).
    • Method Detail

      • add

        public void add​(int value)
        Adds the specified value to the significand in place.
        Parameters:
        value - the addend, must be a non-negative value
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - on overflow
      • fma

        public void fma​(int factor,
                        int addend)
        Multiplies the significand with the specified factor in place, and then adds the specified addend to it (also in place).
        Parameters:
        factor - the multiplication factor, must be a non-negative value
        addend - the addend, must be a non-negative value
        Throws:
        java.lang.ArrayIndexOutOfBoundsException - on overflow
      • toBigInteger

        public java.math.BigInteger toBigInteger()
        Converts the BigSignificand to a BigInteger.
        Returns:
        a new BigInteger instance
      • x

        private void x​(int i,
                       int value)
      • x

        private int x​(int i)