Class ScalarQuantity.DoubleStored<U extends TypedUnit<U>>

    • Field Detail

      • numericalValue

        private final double numericalValue
    • Constructor Detail

      • DoubleStored

        protected DoubleStored​(double numericalValue,
                               U unit)
    • Method Detail

      • intValue

        public int intValue()
        Specified by:
        intValue in class java.lang.Number
      • longValue

        public long longValue()
        Description copied from interface: IQuantity
        Get the numerical quantity value of this quantity as a long. This may cause truncation and loss of precision.
        Specified by:
        longValue in interface IQuantity
        Specified by:
        longValue in class java.lang.Number
        Returns:
        the numerical quantity, as a long
      • floatValue

        public float floatValue()
        Specified by:
        floatValue in class java.lang.Number
      • doubleValue

        public double doubleValue()
        Description copied from interface: IQuantity
        Get the numerical quantity value of this quantity as a double. This may cause loss of precision.
        Specified by:
        doubleValue in interface IQuantity
        Specified by:
        doubleValue in class java.lang.Number
        Returns:
        the numerical quantity, as a double
      • numberValue

        public java.lang.Number numberValue()
        Description copied from interface: IQuantity
        Get the numerical quantity value that this quantity, as either a Long or a Number with at least the precision of double.
        Returns:
        the numerical quantity
      • longValueIn

        public long longValueIn​(IUnit targetUnit,
                                long maxAbsValue)
                         throws QuantityConversionException
        Description copied from interface: IQuantity
        Get the numerical quantity value that this quantity would have if expressed in the unit targetUnit, rounded to a mathematical integer, if that numerical value is in the range [-maxAbsValue-1, maxAbsValue]. Otherwise, an QuantityConversionException will be thrown, with the violation encoded. Note that as a result of this conversion, precision may be lost.
        Returns:
        the numerical quantity, as a long
        Throws:
        QuantityConversionException - if the result would be out of range
        See Also:
        IQuantity.numberValueIn(IUnit)
      • clampedLongValueIn

        public long clampedLongValueIn​(IUnit targetUnit)
        Description copied from interface: IQuantity
        Get the long value closest to the numerical quantity value that this quantity would have if expressed in the unit targetUnit. This means that values outside the range [ Long.MIN_VALUE ,Long.MAX_VALUE] will be clamped to the closest extreme. Note that as a result of this conversion, precision may be lost.

        This method is equivalent to IQuantity.in(IUnit)@.IQuantity.longValue(), but is preferred since it is both cheaper and its name more explicitly conveys the limitations involved.

        Returns:
        the numerical quantity, as a long
        See Also:
        IQuantity.numberValueIn(IUnit)
      • clampedFloorIn

        public long clampedFloorIn​(IUnit targetUnit)
        Description copied from interface: IQuantity
        Get the long value closest to the floor of the numerical quantity value that this quantity would have if expressed in the unit targetUnit. This means that values outside the range[ Long.MIN_VALUE , Long.MAX_VALUE ] will be clamped to the closest extreme. Note that as a result of this conversion, precision may be lost.
        Returns:
        the floor of the numerical quantity, as a long
      • clampedIntFloorIn

        public int clampedIntFloorIn​(IUnit targetUnit)
        Description copied from interface: IQuantity
        Get the int value closest to the floor of the numerical quantity value that this quantity would have if expressed in the unit targetUnit. This means that values outside the range[ Integer.MIN_VALUE , Integer.MAX_VALUE ] will be clamped to the closest extreme. Note that as a result of this conversion, precision may be lost.
        Returns:
        the floor of the numerical quantity, as an int
      • doubleValueIn

        public double doubleValueIn​(IUnit targetUnit)
        Description copied from interface: IQuantity
        Get the numerical quantity value that this quantity would have if expressed in the unit targetUnit, as a double. Note that as a result of this conversion, precision may be lost.
        Returns:
        the numerical quantity, as a double
      • numberValueIn

        public java.lang.Number numberValueIn​(IUnit targetUnit)
        Description copied from interface: IQuantity
        Get the numerical quantity value that this quantity would have if expressed in the unit targetUnit, as either a Long or a Number with at least the precision of double. If this quantity is exact, the unit conversion is known to be exact, and the result can be exactly represented in a long, a Long will be returned. Otherwise, some other Number implementation, such as Double will be returned. Note that as a result of this conversion, precision may be lost.
        Returns:
        the numerical quantity, as a Long if exact, otherwise as some other Number
        See Also:
        IQuantity.clampedLongValueIn(IUnit)
      • persistableString

        public java.lang.String persistableString()
        Description copied from interface: IQuantity
        A string representation independent of locale or internationalization, that when parsed using KindOfQuantity.parsePersisted(String) (by this quantity's kind of quantity) yields a value that is equal to this quantity. That is, the exact representation must be preserved.
        Returns:
        a string representation independent of locale or internationalization.
      • localizedFormat

        public java.lang.String localizedFormat​(boolean useBreakingSpace,
                                                boolean allowCustomUnit)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • multiply

        public ITypedQuantity<U> multiply​(long factor)
                                   throws java.lang.UnsupportedOperationException
        Description copied from interface: IQuantity
        Returns a new quantity that is this quantity multiplied with factor, if this is a linear quantity. Otherwise, this operation is undefined and UnsupportedOperationException will be thrown.
        Returns:
        this quantity multiplied with factor
        Throws:
        java.lang.UnsupportedOperationException - if this quantity is not linear
      • multiply

        public ITypedQuantity<U> multiply​(double factor)
                                   throws java.lang.UnsupportedOperationException
        Description copied from interface: IQuantity
        Returns a new quantity that is this quantity multiplied with factor, if this is a linear quantity. Otherwise, this operation is undefined and UnsupportedOperationException will be thrown.
        Returns:
        this quantity multiplied with factor
        Throws:
        java.lang.UnsupportedOperationException - if this quantity is not linear
      • ratioTo

        public double ratioTo​(IQuantity denominator)
                       throws java.lang.UnsupportedOperationException,
                              java.lang.IllegalArgumentException
        Description copied from interface: IQuantity
        Compute the ratio of this quantity to the given consequent quantity, if both are of the same linear kind. Otherwise, this operation is undefined and an exception is thrown.
        Returns:
        the ratio of this quantity to consequent, as a double fraction
        Throws:
        java.lang.UnsupportedOperationException - if this quantity is not linear
        java.lang.IllegalArgumentException - if consequent is not of a compatible kind of quantity