public class FloatTime extends AbstractFloatScalarAbs<TimeUnit,FloatTime,DurationUnit,FloatDuration>
FloatScalar.Abs<TimeUnit> value = new FloatScalar.Abs<TimeUnit>(100.0, TimeUnit.SI);we can now write:
FloatTime value = new FloatTime(100.0, TimeUnit.SI);The compiler will automatically recognize which units belong to which quantity, and whether the quantity type and the unit used are compatible.
Note that when the offset of a stored absolute Time becomes large, precision of a float might not be enough for the required resolution of a Time. A float has around 7 significant digits (23 bit mantissa). This means that when we need to have a float time that is precise to microseconds, the Time value should not go above 2^22 = 4.0E6. This is not enough to store Epoch values that are in the order of magnitude of 2E12 ms! So feeding System.TimeInMillis() to a FloatTime with TimeUnit.BASE as its unit is not having the required precision. At best, a FloatTime can store TimeUnit.BASE or TimeUnit.EPOCH values with real calendar values with a precision of several minutes.
Copyright (c) 2013-2019 Delft University of Technology, PO Box 5, 2600 AA, Delft, the Netherlands.
All rights reserved.
BSD-style license. See OpenTrafficSim License.
$LastChangedDate: 2019-01-18 00:35:01 +0100 (Fri, 18 Jan 2019) $, @version $Revision: 324 $, by $Author: averbraeck $,
initial version Sep 1, 2015
Modifier and Type | Field and Description |
---|---|
static FloatTime |
ZERO
constant with value zero.
|
si
Constructor and Description |
---|
FloatTime(double value,
TimeUnit unit)
Construct FloatTime scalar using a double value.
|
FloatTime(FloatTime value)
Construct FloatTime scalar.
|
FloatTime(float value,
TimeUnit unit)
Construct FloatTime scalar.
|
Modifier and Type | Method and Description |
---|---|
static FloatTime |
createSI(float value)
Construct FloatTime scalar.
|
FloatTime |
instantiateAbs(float value,
TimeUnit unit)
Construct a new Absolute Immutable FloatScalar of the right type.
|
FloatDuration |
instantiateRel(float value,
DurationUnit unit)
Construct a new Relative Immutable FloatScalar of the right type.
|
static FloatTime |
interpolate(FloatTime zero,
FloatTime one,
float ratio)
Interpolate between two values.
|
static FloatTime |
max(FloatTime a1,
FloatTime a2)
Return the maximum value of two absolute scalars.
|
static FloatTime |
max(FloatTime a1,
FloatTime a2,
FloatTime... an)
Return the maximum value of more than two absolute scalars.
|
static FloatTime |
min(FloatTime a1,
FloatTime a2)
Return the minimum value of two absolute scalars.
|
static FloatTime |
min(FloatTime a1,
FloatTime a2,
FloatTime... an)
Return the minimum value of more than two absolute scalars.
|
ceil, divideBy, floor, minus, minus, multiplyBy, plus, rint, round
compareTo, doubleValue, eq, eq0, equals, floatValue, ge, ge0, getInUnit, getInUnit, getSI, gt, gt0, hashCode, intValue, le, le0, longValue, lt, lt0, ne, ne0, toString, toString, toString, toString
expressAsSIUnit, expressAsSpecifiedUnit, getUnit, isAbsolute, isRelative, setDisplayUnit
byteValue, shortValue
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
DIV, MULT, POW
public static final FloatTime ZERO
public FloatTime(float value, TimeUnit unit)
value
- float; float valueunit
- TimeUnit; unit for the float valuepublic FloatTime(double value, TimeUnit unit)
value
- double; double valueunit
- TimeUnit; unit for the resulting float valuepublic FloatTime(FloatTime value)
value
- FloatTime; Scalar from which to construct this instancepublic final FloatTime instantiateAbs(float value, TimeUnit unit)
instantiateAbs
in class AbstractFloatScalarAbs<TimeUnit,FloatTime,DurationUnit,FloatDuration>
value
- float; the float valueunit
- AU; the unitpublic final FloatDuration instantiateRel(float value, DurationUnit unit)
instantiateRel
in class AbstractFloatScalarAbs<TimeUnit,FloatTime,DurationUnit,FloatDuration>
value
- float; the float valueunit
- RU; the unitpublic static final FloatTime createSI(float value)
value
- float; float value in BASE unitspublic static FloatTime interpolate(FloatTime zero, FloatTime one, float ratio)
zero
- FloatTime; the low valueone
- FloatTime; the high valueratio
- float; the ratio between 0 and 1, inclusivepublic static FloatTime max(FloatTime a1, FloatTime a2)
a1
- FloatTime; the first scalara2
- FloatTime; the second scalarpublic static FloatTime max(FloatTime a1, FloatTime a2, FloatTime... an)
a1
- FloatTime; the first scalara2
- FloatTime; the second scalaran
- FloatTime...; the other scalarspublic static FloatTime min(FloatTime a1, FloatTime a2)
a1
- FloatTime; the first scalara2
- FloatTime; the second scalarpublic static FloatTime min(FloatTime a1, FloatTime a2, FloatTime... an)
a1
- FloatTime; the first scalara2
- FloatTime; the second scalaran
- FloatTime...; the other scalarsCopyright © 2015–2019 Delft University of Technology. All rights reserved.