Class IntApfloatImpl

  • All Implemented Interfaces:
    java.io.Serializable, ApfloatImpl

    public class IntApfloatImpl
    extends IntBaseMath
    implements ApfloatImpl
    Immutable apfloat implementation class for the int data element type.

    The associated DataStorage is assumed to be immutable also. This way performance can be improved by sharing the data storage between different ApfloatImpl's and by only varying the ApfloatImpl specific fields, like sign, precision and exponent.

    This implementation doesn't necessarily store any extra digits for added precision, so the last digit of any operation may be inaccurate.

    Version:
    1.11.0
    See Also:
    Serialized Form
    • Field Detail

      • sign

        private int sign
      • precision

        private long precision
      • exponent

        private long exponent
      • radix

        private int radix
      • hashCode

        private int hashCode
      • initialDigits

        private int initialDigits
      • isOne

        private int isOne
      • leastZeros

        private volatile long leastZeros
      • size

        private volatile long size
    • Constructor Detail

      • IntApfloatImpl

        private IntApfloatImpl​(int sign,
                               long precision,
                               long exponent,
                               DataStorage dataStorage,
                               int radix)
      • IntApfloatImpl

        public IntApfloatImpl​(java.lang.String value,
                              long precision,
                              int radix,
                              boolean isInteger)
                       throws java.lang.NumberFormatException,
                              ApfloatRuntimeException
        Create a new IntApfloatImpl instance from a String.
        Parameters:
        value - The string to be parsed to a number.
        precision - The precision of the number (in digits of the radix).
        radix - The radix in which the number is created.
        isInteger - Specifies if the number to be parsed from the string is to be treated as an integer or not.
        Throws:
        java.lang.NumberFormatException - If the number is not valid.
        ApfloatRuntimeException
      • IntApfloatImpl

        public IntApfloatImpl​(long value,
                              long precision,
                              int radix)
                       throws java.lang.NumberFormatException,
                              ApfloatRuntimeException
        Create a new IntApfloatImpl instance from a long.
        Parameters:
        value - The value of the number.
        precision - The precision of the number (in digits of the radix).
        radix - The radix in which the number is created.
        Throws:
        java.lang.NumberFormatException - If the number is not valid.
        ApfloatRuntimeException
      • IntApfloatImpl

        public IntApfloatImpl​(double value,
                              long precision,
                              int radix)
                       throws java.lang.NumberFormatException,
                              ApfloatRuntimeException
        Create a new IntApfloatImpl instance from a double.
        Parameters:
        value - The value of the number.
        precision - The precision of the number (in digits of the radix).
        radix - The radix in which the number is created.
        Throws:
        java.lang.NumberFormatException - If the number is not valid.
        ApfloatRuntimeException
      • IntApfloatImpl

        public IntApfloatImpl​(java.io.PushbackReader in,
                              long precision,
                              int radix,
                              boolean isInteger)
                       throws java.io.IOException,
                              java.lang.NumberFormatException,
                              ApfloatRuntimeException
        Create a new IntApfloatImpl instance reading from a stream.

        Implementation note: this constructor calls the in stream's single-character read() method. If the underlying stream doesn't explicitly implement this method in some efficient way, but simply inherits it from the Reader base class, performance will suffer as the default Reader method creates a new char[1] on every call to read().

        Parameters:
        in - The stream to read from.
        precision - The precision of the number (in digits of the radix).
        radix - The radix in which the number is created.
        isInteger - Specifies if the number to be parsed from the stream is to be treated as an integer or not.
        Throws:
        java.io.IOException - If an I/O error occurs accessing the stream.
        java.lang.NumberFormatException - If the number is not valid.
        ApfloatRuntimeException