Package gnu.math
Class Unit
- java.lang.Object
-
- java.lang.Number
-
- gnu.math.Numeric
-
- gnu.math.Quantity
-
- gnu.math.Unit
-
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
NamedUnit
public abstract class Unit extends Quantity
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static Unitcmstatic NamedUnitdatestatic Unitdegreestatic BaseUnitdurationstatic BaseUnitEmptystatic Unitgradianstatic BaseUnitgramstatic Unithourstatic Unitinstatic BaseUnitmeterstatic Unitminutestatic Unitmmstatic NamedUnitmonthstatic doubleNON_COMBINABLEA magic factor to indicate units that have the same "dimension" but not a fixed multiple.static Unitpicastatic Unitptstatic Unitradianstatic NamedUnitsecond
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Unitdefine(String name, double factor, Unit base)static Unitdefine(String name, DQuantity value)Dimensionsdimensions()static Unitdivide(Unit unit1, Unit unit2)doubledoubleValue()The value of the real component, as a double.StringgetName()inthashCode()booleanisExact()booleanisZero()static NamedUnitlookup(String name)static NamedUnitmake(String name, Quantity value)Complexnumber()static Unitpow(Unit unit, int power)Numericpower(IntNum y)Return this raised to an integer power.Unitsqrt()static Unittimes(Unit unit1, Unit unit2)StringtoString()StringtoString(double val)StringtoString(RealNum val)Unitunit()-
Methods inherited from class gnu.math.Quantity
abs, add, add, addReversed, compare, compare, compareReversed, div, divide, divReversed, doubleImagValue, doubleJmagValue, doubleKmagValue, im, imValue, jm, jmValue, km, kmValue, make, make, make, mul, mulReversed, neg, re, reValue, times, toString
-
Methods inherited from class gnu.math.Numeric
add, asNumericOrNull, div_inv, equals, floatValue, geq, grt, intValue, longValue, mul_ident, sub, toExact, toInexact
-
Methods inherited from class java.lang.Number
byteValue, shortValue
-
-
-
-
Field Detail
-
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 Detail
-
dimensions
public final Dimensions dimensions()
- Overrides:
dimensionsin classQuantity
-
doubleValue
public final double doubleValue()
Description copied from class:QuantityThe value of the real component, as a double. This is relative to the unit().dims - i.e. unit()/doubleValue() is factored in.- Overrides:
doubleValuein classQuantity
-
getName
public String getName()
-
power
public Numeric power(IntNum y)
Description copied from class:NumericReturn this raised to an integer power. Implemented by repeated squaring and multiplication. Ify < 0, returns div_inv of the result.
-
sqrt
public Unit sqrt()
-
toString
public String toString(double val)
-
-