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 Unit
cm
static NamedUnit
date
static Unit
degree
static BaseUnit
duration
static BaseUnit
Empty
static Unit
gradian
static BaseUnit
gram
static Unit
hour
static Unit
in
static BaseUnit
meter
static Unit
minute
static Unit
mm
static NamedUnit
month
static double
NON_COMBINABLE
A magic factor to indicate units that have the same "dimension" but not a fixed multiple.static Unit
pica
static Unit
pt
static Unit
radian
static NamedUnit
second
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Unit
define(String name, double factor, Unit base)
static Unit
define(String name, DQuantity value)
Dimensions
dimensions()
static Unit
divide(Unit unit1, Unit unit2)
double
doubleValue()
The value of the real component, as a double.String
getName()
int
hashCode()
boolean
isExact()
boolean
isZero()
static NamedUnit
lookup(String name)
static NamedUnit
make(String name, Quantity value)
Complex
number()
static Unit
pow(Unit unit, int power)
Numeric
power(IntNum y)
Return this raised to an integer power.Unit
sqrt()
static Unit
times(Unit unit1, Unit unit2)
String
toString()
String
toString(double val)
String
toString(RealNum val)
Unit
unit()
-
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:
dimensions
in classQuantity
-
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 classQuantity
-
getName
public String getName()
-
power
public Numeric power(IntNum y)
Description copied from class:Numeric
Return 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)
-
-