Class DoubleScalar<U extends Unit<U>,S extends DoubleScalar<U,S>>

java.lang.Object
java.lang.Number
org.djunits.value.base.Scalar<U,S>
org.djunits.value.vdouble.scalar.base.DoubleScalar<U,S>
Type Parameters:
U - the unit
S - the type
All Implemented Interfaces:
Serializable, Cloneable, Comparable<S>, Value<U,S>
Direct Known Subclasses:
DoubleScalarAbs, DoubleScalarRel

public abstract class DoubleScalar<U extends Unit<U>,S extends DoubleScalar<U,S>> extends Scalar<U,S>
The most basic abstract class for the DoubleScalar.

Copyright (c) 2013-2025 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands. All rights reserved.
BSD-style license. See DJUNITS License.

Author:
Alexander Verbraeck, Peter Knoppers
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    final double
    The value, stored in the standard SI unit.
  • Constructor Summary

    Constructors
    Constructor
    Description
    DoubleScalar(double value, U unit)
    Construct a new DoubleScalar.
    DoubleScalar(S value)
    Construct a new DoubleScalar.
  • Method Summary

    Modifier and Type
    Method
    Description
    final int
     
    double
     
    final boolean
    eq(S o)
    Test if this DoubleScalar is equal to another DoubleScalar.
    final boolean
    eq0()
    Test if this DoubleScalar is equal to 0.0.
    boolean
     
    float
     
    final boolean
    ge(S o)
    Test if this DoubleScalar is greater than or equal to another DoubleScalar.
    final boolean
    ge0()
    Test if this DoubleScalar is greater than or equal to 0.0.
    final double
    Retrieve the value in the original unit.
    final double
    getInUnit(U targetUnit)
    Retrieve the value converted into some specified unit.
    final double
    Retrieve the value in the underlying SI unit.
    final boolean
    gt(S o)
    Test if this DoubleScalar is greater than another DoubleScalar.
    final boolean
    gt0()
    Test if this DoubleScalar is greater than 0.0.
    int
     
    int
     
    final boolean
    le(S o)
    Test if this DoubleScalar is less than or equal to another DoubleScalar.
    final boolean
    le0()
    Test if this DoubleScalar is less than or equal to 0.0.
    long
     
    final boolean
    lt(S o)
    Test if this DoubleScalar is less than another DoubleScalar.
    final boolean
    lt0()
    Test if this DoubleScalar is less than 0.0.
    final boolean
    ne(S o)
    Test if this DoubleScalar is not equal to another DoubleScalar.
    final boolean
    ne0()
    Test if this DoubleScalar is not equal to 0.0.
    Concise display description of this value, without the engineering formatting, so without trailing zeroes.
    toDisplayString(U displayUnit)
    Concise display description of this value, without the engineering formatting, so without trailing zeroes.
    Concise description of this value.
    toString(boolean verbose, boolean withUnit)
    Somewhat verbose description of this value with optional type and unit information.
    toString(U displayUnit)
    Somewhat verbose description of this value with the values expressed in the specified unit.
    toString(U displayUnit, boolean verbose, boolean withUnit)
    Somewhat verbose description of this value with the values expressed in the specified unit.
    Format this DoubleScalar in SI unit using prefixes when possible.
    toStringSIPrefixed(int smallestPower, int biggestPower)
    Format this DoubleScalar in SI unit using prefixes when possible and within the specified size range.
    Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.
    toTextualString(U displayUnit)
    Concise textual representation of this value, without the engineering formatting, so without trailing zeroes.

    Methods inherited from class org.djunits.value.base.Scalar

    format, format, getDisplayUnit, setDisplayUnit

    Methods inherited from class java.lang.Number

    byteValue, shortValue

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.djunits.value.Value

    abs, ceil, floor, isAbsolute, isRelative, neg, rint
  • Field Details

    • si

      public final double si
      The value, stored in the standard SI unit.
  • Constructor Details

    • DoubleScalar

      public DoubleScalar(double value, U unit)
      Construct a new DoubleScalar.
      Parameters:
      value - the value to store, expressed in the given unit
      unit - the unit
    • DoubleScalar

      public DoubleScalar(S value)
      Construct a new DoubleScalar.
      Parameters:
      value - the value to duplicate
  • Method Details

    • getSI

      public final double getSI()
      Retrieve the value in the underlying SI unit.
      Returns:
      double
    • getInUnit

      public final double getInUnit()
      Retrieve the value in the original unit.
      Returns:
      double
    • getInUnit

      public final double getInUnit(U targetUnit)
      Retrieve the value converted into some specified unit.
      Parameters:
      targetUnit - the unit to convert the value into
      Returns:
      double
    • lt

      public final boolean lt(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is less than another DoubleScalar.
      Specified by:
      lt in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is less than o; false otherwise
    • le

      public final boolean le(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is less than or equal to another DoubleScalar.
      Specified by:
      le in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is less than or equal to o; false otherwise
    • gt

      public final boolean gt(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is greater than another DoubleScalar.
      Specified by:
      gt in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is greater than o; false otherwise
    • ge

      public final boolean ge(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is greater than or equal to another DoubleScalar.
      Specified by:
      ge in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is greater than or equal to o; false otherwise
    • eq

      public final boolean eq(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is equal to another DoubleScalar.
      Specified by:
      eq in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is equal to o; false otherwise
    • ne

      public final boolean ne(S o)
      Description copied from class: Scalar
      Test if this DoubleScalar is not equal to another DoubleScalar.
      Specified by:
      ne in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      o - the right hand side operand of the comparison
      Returns:
      true if this is not equal to o; false otherwise
    • lt0

      public final boolean lt0()
      Description copied from class: Scalar
      Test if this DoubleScalar is less than 0.0.
      Specified by:
      lt0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is less than 0.0; false if this is not less than 0.0
    • le0

      public final boolean le0()
      Description copied from class: Scalar
      Test if this DoubleScalar is less than or equal to 0.0.
      Specified by:
      le0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is less than or equal to 0.0; false if this is not less than or equal to 0.0
    • gt0

      public final boolean gt0()
      Description copied from class: Scalar
      Test if this DoubleScalar is greater than 0.0.
      Specified by:
      gt0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is greater than 0.0; false if this is not greater than 0.0
    • ge0

      public final boolean ge0()
      Description copied from class: Scalar
      Test if this DoubleScalar is greater than or equal to 0.0.
      Specified by:
      ge0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is greater than or equal to 0.0; false if this is not greater than or equal to 0.0
    • eq0

      public final boolean eq0()
      Description copied from class: Scalar
      Test if this DoubleScalar is equal to 0.0.
      Specified by:
      eq0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is equal to 0.0; false if this is not equal to 0.0
    • ne0

      public final boolean ne0()
      Description copied from class: Scalar
      Test if this DoubleScalar is not equal to 0.0.
      Specified by:
      ne0 in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      true if this is not equal to 0.0; false if this is equal to 0.0
    • compareTo

      public final int compareTo(S o)
    • intValue

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

      public long longValue()
      Specified by:
      longValue in class Number
    • floatValue

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

      public double doubleValue()
      Specified by:
      doubleValue in class Number
    • toString

      public String toString()
      Description copied from interface: Value
      Concise description of this value.
      Specified by:
      toString in interface Value<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Overrides:
      toString in class Object
      Returns:
      a String with the value, non-verbose, with the unit attached.
    • toString

      public String toString(U displayUnit)
      Description copied from interface: Value
      Somewhat verbose description of this value with the values expressed in the specified unit.
      Parameters:
      displayUnit - the unit into which the values are converted for display
      Returns:
      printable string with the value contents expressed in the specified unit
    • toString

      public String toString(boolean verbose, boolean withUnit)
      Description copied from interface: Value
      Somewhat verbose description of this value with optional type and unit information.
      Parameters:
      verbose - if true; include type info; if false; exclude type info
      withUnit - if true; include the unit; of false; exclude the unit
      Returns:
      printable string with the value contents
    • toString

      public String toString(U displayUnit, boolean verbose, boolean withUnit)
      Description copied from interface: Value
      Somewhat verbose description of this value with the values expressed in the specified unit.
      Parameters:
      displayUnit - the unit into which the values are converted for display
      verbose - if true; include type info; if false; exclude type info
      withUnit - if true; include the unit; of false; exclude the unit
      Returns:
      printable string with the value contents
    • toStringSIPrefixed

      public String toStringSIPrefixed()
      Format this DoubleScalar in SI unit using prefixes when possible. If the value is too small or too large, e-notation and the plain SI unit are used.
      Returns:
      formatted value of this DoubleScalar
    • toStringSIPrefixed

      public String toStringSIPrefixed(int smallestPower, int biggestPower)
      Format this DoubleScalar in SI unit using prefixes when possible and within the specified size range. If the value is too small or too large, e-notation and the plain SI unit are used.
      Parameters:
      smallestPower - the smallest exponent value that will be written using an SI prefix
      biggestPower - the largest exponent value that will be written using an SI prefix
      Returns:
      formatted value of this DoubleScalar
    • toTextualString

      public String toTextualString()
      Description copied from class: Scalar
      Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Specified by:
      toTextualString in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      a String with the value with the default textual representation of the unit attached.
    • toTextualString

      public String toTextualString(U displayUnit)
      Description copied from class: Scalar
      Concise textual representation of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Specified by:
      toTextualString in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      displayUnit - the display unit for the value
      Returns:
      a String with the value with the default textual representation of the provided unit attached.
    • toDisplayString

      public String toDisplayString()
      Description copied from class: Scalar
      Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Specified by:
      toDisplayString in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Returns:
      a String with the value with the default display representation of the unit attached.
    • toDisplayString

      public String toDisplayString(U displayUnit)
      Description copied from class: Scalar
      Concise display description of this value, without the engineering formatting, so without trailing zeroes. A space is added between the number and the unit.
      Specified by:
      toDisplayString in class Scalar<U extends Unit<U>,S extends DoubleScalar<U,S>>
      Parameters:
      displayUnit - the display unit for the value
      Returns:
      a String with the value with the default display representation of the provided unit attached.
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object