Package gnu.math

Class Unit

All Implemented Interfaces:
Serializable
Direct Known Subclasses:
NamedUnit

public abstract class Unit extends Quantity
See Also:
  • Field Details

    • Empty

      public static BaseUnit Empty
    • NON_COMBINABLE

      public static double NON_COMBINABLE
      A magic factor to indicate units that have the same "dimension" but not a fixed multiple. E.g. "month" and "day", or money of different currencies. Since they have the same dimension, they can be added to get an (unimplemented) combined quantity, but they cannot be compared. No general support yet, but used for time Duration.
    • meter

      public static final BaseUnit meter
    • duration

      public static final BaseUnit duration
    • gram

      public static final BaseUnit gram
    • cm

      public static final Unit cm
    • mm

      public static final Unit mm
    • in

      public static final Unit in
    • pt

      public static final Unit pt
    • pica

      public static final Unit pica
    • radian

      public static final Unit radian
    • degree

      public static final Unit degree
    • gradian

      public static final Unit gradian
    • date

      public static final NamedUnit date
    • second

      public static final NamedUnit second
    • month

      public static final NamedUnit month
    • minute

      public static final Unit minute
    • hour

      public static final Unit hour
  • Method Details

    • dimensions

      public final Dimensions dimensions()
      Overrides:
      dimensions in class Quantity
    • doubleValue

      public final double doubleValue()
      Description copied from class: Quantity
      The value of the real component, as a double. This is relative to the unit().dims - i.e. unit()/doubleValue() is factored in.
      Overrides:
      doubleValue in class Quantity
    • hashCode

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

      public String getName()
    • times

      public static Unit times(Unit unit1, Unit unit2)
    • divide

      public static Unit divide(Unit unit1, Unit unit2)
    • pow

      public static Unit pow(Unit unit, int power)
    • make

      public static NamedUnit make(String name, Quantity value)
    • define

      public static Unit define(String name, DQuantity value)
    • define

      public static Unit define(String name, double factor, Unit base)
    • number

      public Complex number()
      Specified by:
      number in class Quantity
    • isExact

      public boolean isExact()
      Specified by:
      isExact in class Numeric
    • isZero

      public final boolean isZero()
      Specified by:
      isZero in class Numeric
    • power

      public Numeric power(IntNum y)
      Description copied from class: Numeric
      Return this raised to an integer power. Implemented by repeated squaring and multiplication. If y < 0, returns div_inv of the result.
      Overrides:
      power in class Numeric
    • sqrt

      public Unit sqrt()
    • lookup

      public static NamedUnit lookup(String name)
    • toString

      public String toString(double val)
    • toString

      public String toString(RealNum val)
    • toString

      public String toString()
      Overrides:
      toString in class Numeric
    • unit

      public Unit unit()
      Overrides:
      unit in class Quantity