java.lang.Object
ch.randelshofer.fastdoubleparser.BigSignificand

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

    Fields
    Modifier and Type
    Field
    Description
    private int
     
    private static final long
     
    private final int
     
    private static final VarHandle
     
    private final byte[]
     
  • Constructor Summary

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

    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).
    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 Details

    • LONG_MASK

      private static final long LONG_MASK
      See Also:
    • readIntBE

      private static final VarHandle readIntBE
    • numInts

      private final int numInts
    • x

      private final byte[] x
    • firstNonZeroInt

      private int firstNonZeroInt
  • Constructor Details

    • 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 Details

    • 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:
      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:
      ArrayIndexOutOfBoundsException - on overflow
    • toBigInteger

      public 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)