final class Temperature extends Quantity[Temperature]
Represents a quantity of temperature
Temperatures are somewhat unique in the world of quantities for a couple of reasons.
First, different units (scales) have different "zero" values. This means that these scales are not simple multiples of the others. There is a "zero offset" that must be applied to conversions from one scale to another.
Second, temperatures are often quoted as though they were quantities, when in fact they are just points on a scale. Similar to a mile marker on a highway, the quantity represented is the number degrees (miles) from a specific "zero" value on the scale.
In fact an absolute quantity of thermodynamic temperature should be measured from absolute zero. Thus, Kelvin, is the SI Base unit for temperature.
The other scales supported here, Celsius and Fahrenheit, are known as empirical scales. Of course, these scales set their respective zero values well above absolute zero. This is done to provide a granular and reasonably sized ranges of values for dealing with everyday temperatures.
This library supports another absolute scale, the Rankine scale. Rankine sets its zero at absolute zero, but degrees are measure in Fahrenheit (as opposed to Celsius, as the Kelvin scale uses).
In consideration of these more unique scale conversions, two conversion types are supported: Degrees and Scale.
Scale based conversions DO adjust for the zero offset. Thus 5 degrees C is the same as 41 degrees F on the thermometer.
Degrees based conversions DO NOT adjust for the zero point. Thus 5 degrees C|K is the same amount of temperature as 9 degrees F|R.
When creating a temperature it is not important to consider these differences. It is also irrelevant when performing operation on temperatures in the same scale. However, when performing operations on two temperatures of different scales these factors do become important.
The Quantity.to(unit) and Quantity.in(unit) methods are overridden to use Scale conversions for convenience
The Ordered.compare method is implemented to use Scale conversions
The Quantity.plus and Quantity.minus methods are implemented to treat right operands as Quantity of Degrees and not a scale Temperature. Operands that differ in scale will use Degree conversions. This supports mixed scale expressions:
val temp = Fahrenheit(100) - Celsius(5) // returns Fahrenheit(91)
This also supports declaring temperature ranges using typical nomenclature:
val tempRange = 65.F +- 5.C // returns QuantityRange(56.0°F,74.0°F)
The toDegrees(unit) methods are implemented to use Degree conversions.
- Source
- Temperature.scala
- Since
0.1
- Alphabetic
- By Inheritance
- Temperature
- Quantity
- Ordered
- Comparable
- Serializable
- Serializable
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
%(that: Temperature): Double
- Definition Classes
- Quantity
-
def
%(that: Double): Temperature
- Definition Classes
- Quantity
- def *(that: ThermalCapacity): energy.Energy
-
def
*(that: Price[Temperature]): Money
- Definition Classes
- Quantity
-
def
*(that: Double): Temperature
- Definition Classes
- Quantity
-
def
+(that: Temperature): Temperature
- Definition Classes
- Quantity
-
def
+-(that: Temperature): QuantityRange[Temperature]
- Definition Classes
- Quantity
-
def
-(that: Temperature): Temperature
- Definition Classes
- Quantity
-
def
/(that: Temperature): Double
- Definition Classes
- Quantity
-
def
/(that: Double): Temperature
- Definition Classes
- Quantity
-
def
/%(that: Temperature): (Double, Temperature)
- Definition Classes
- Quantity
-
def
/%(that: Double): (Temperature, Temperature)
- Definition Classes
- Quantity
-
def
<(that: Temperature): Boolean
- Definition Classes
- Ordered
-
def
<=(that: Temperature): Boolean
- Definition Classes
- Ordered
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
=~(that: Temperature)(implicit tolerance: Temperature): Boolean
approx
approx
- Definition Classes
- Quantity
-
def
>(that: Temperature): Boolean
- Definition Classes
- Ordered
-
def
>=(that: Temperature): Boolean
- Definition Classes
- Ordered
-
def
abs: Temperature
Returns the absolute value of this Quantity
-
def
approx(that: Temperature)(implicit tolerance: Temperature): Boolean
Returns boolean result of approximate equality comparison
Returns boolean result of approximate equality comparison
- that
Quantity
- tolerance
Quantity
- Definition Classes
- Quantity
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
ceil: Temperature
Returns the smallest (closest to negative infinity) Quantity value that is greater than or equal to the argument and is equal to a mathematical integer.
Returns the smallest (closest to negative infinity) Quantity value that is greater than or equal to the argument and is equal to a mathematical integer.
- returns
Quantity
- Definition Classes
- Quantity
- See also
java.lang.Math#ceil(double)
-
def
clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
compare(that: Temperature): Int
Implements Ordered.compare
-
def
compareTo(that: Temperature): Int
- Definition Classes
- Ordered → Comparable
-
def
dimension: Temperature.type
The Dimension this quantity represents
The Dimension this quantity represents
- Definition Classes
- Temperature → Quantity
-
def
divide(that: Temperature): Double
Divide this quantity by a like quantity
-
def
divide(that: Double): Temperature
Divide this quantity by some number
-
def
divideAndRemainder(that: Temperature): (Double, Temperature)
Returns a Pair that includes the result of divideToInteger and remainder
Returns a Pair that includes the result of divideToInteger and remainder
- that
Quantity
- returns
(Double, Quantity)
- Definition Classes
- Quantity
-
def
divideAndRemainder(that: Double): (Temperature, Temperature)
Returns a Pair that includes the result of divideToInteger and remainder
Returns a Pair that includes the result of divideToInteger and remainder
- that
Double
- returns
(Quantity, Quantity)
- Definition Classes
- Quantity
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(that: Any): Boolean
Override of equals method
Override of equals method
- that
must be of matching value and unit
- Definition Classes
- Quantity → AnyRef → Any
-
def
finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
floor: Temperature
Returns the largest (closest to positive infinity) Quantity value that is less than or equal to the argument and is equal to a mathematical integer
Returns the largest (closest to positive infinity) Quantity value that is less than or equal to the argument and is equal to a mathematical integer
- returns
Quantity
- Definition Classes
- Quantity
- See also
java.lang.Math#floor(double)
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
hashCode(): Int
Override of hashCode
Override of hashCode
- Definition Classes
- Quantity → AnyRef → Any
- def in(unit: TemperatureScale): Temperature
-
def
in(uom: UnitOfMeasure[Temperature]): Temperature
Returns an equivalent Quantity boxed with the supplied Unit
Returns an equivalent Quantity boxed with the supplied Unit
- uom
UnitOfMeasure[A]
- returns
Quantity
- Definition Classes
- Quantity
- def inCelsius: Temperature
- def inFahrenheit: Temperature
- def inKelvin: Temperature
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
map(f: (Double) ⇒ Double): Temperature
Applies a function to the underlying value of the Quantity, returning a new Quantity in the same unit
Applies a function to the underlying value of the Quantity, returning a new Quantity in the same unit
- f
Double => Double function
- Definition Classes
- Quantity
-
def
max(that: Temperature): Temperature
Returns the max of this and that Quantity
-
def
min(that: Temperature): Temperature
Returns the min of this and that Quantity
-
def
minus(that: Temperature): Temperature
Subtract two like quantities
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
negate: Temperature
Returns the negative value of this Quantity
-
def
notWithin(range: QuantityRange[Temperature]): Boolean
Returns true if this value is not within (contains) the range
Returns true if this value is not within (contains) the range
- range
QuantityRange
- returns
Boolean
- Definition Classes
- Quantity
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
plus(that: Temperature): Temperature
Add two like quantities
-
def
plusOrMinus(that: Temperature): QuantityRange[Temperature]
Returns a QuantityRange representing the range for this value +- that
Returns a QuantityRange representing the range for this value +- that
- that
Quantity
- returns
QuantityRange
- Definition Classes
- Quantity
-
def
remainder(that: Temperature): Double
Returns the remainder of a division by a like quantity
Returns the remainder of a division by a like quantity
- that
Quantity
- returns
Double
- Definition Classes
- Quantity
-
def
remainder(that: Double): Temperature
Returns the remainder of a division by a number
Returns the remainder of a division by a number
- that
Quantity
- returns
Quantity
- Definition Classes
- Quantity
-
def
rint: Temperature
Returns the Quantity value that is closest in value to the argument and is equal to a mathematical integer.
Returns the Quantity value that is closest in value to the argument and is equal to a mathematical integer.
- returns
Quantity
- Definition Classes
- Quantity
- See also
java.lang.Math#rint(double)
-
def
rounded(scale: Int, mode: RoundingMode = RoundingMode.HALF_EVEN): Temperature
Returns the Quantity with its coefficient value rounded using scale and mode.
Returns the Quantity with its coefficient value rounded using scale and mode. The unit is maintained.
- scale
Int - scale of the value to be returned
- mode
RoundingMode - defaults to HALF_EVEN
- returns
Quantity
- Definition Classes
- Quantity
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
times(that: Double): Temperature
Multiply this quantity by some number
- def to(unit: TemperatureScale): Double
-
def
to(uom: UnitOfMeasure[Temperature]): Double
Returns a Double representing the quantity in terms of the supplied unit
Returns a Double representing the quantity in terms of the supplied unit
val d = Feet(3) (d to Inches) should be(36)
- uom
UnitOfMeasure[A]
- returns
Double
- Definition Classes
- Quantity
-
def
to(that: Temperature): QuantityRange[Temperature]
Returns a QuantityRange that goes from this to that
Returns a QuantityRange that goes from this to that
- that
Quantity
- returns
QuantityRange
- Definition Classes
- Quantity
- def toCelsiusDegrees: Double
- def toCelsiusScale: Double
- def toDegrees(unit: TemperatureScale): Double
- def toFahrenheitDegrees: Double
- def toFahrenheitScale: Double
- def toKelvinDegrees: Double
- def toKelvinScale: Double
- def toScale(unit: TemperatureScale): Double
- def toString(unit: TemperatureScale): String
-
def
toString(): String
Returns a string representing the quantity's value in unit
Returns a string representing the quantity's value in unit
- returns
String
- Definition Classes
- Temperature → Quantity → AnyRef → Any
-
def
toString(uom: UnitOfMeasure[Temperature], format: String): String
Returns a string representing the quantity's value in the given
unit
in the givenformat
Returns a string representing the quantity's value in the given
unit
in the givenformat
- uom
UnitOfMeasure[A] with UnitConverter
- format
String containing the format for the value (ie "%.3f")
- returns
String
- Definition Classes
- Quantity
-
def
toString(uom: UnitOfMeasure[Temperature]): String
Returns a string representing the quantity's value in the given
unit
Returns a string representing the quantity's value in the given
unit
- uom
UnitOfMeasure[A] with UnitConverter
- returns
String
- Definition Classes
- Quantity
-
def
toTuple(uom: UnitOfMeasure[Temperature]): (Double, String)
Returns a pair representing the numeric value and the uom's symbol
Returns a pair representing the numeric value and the uom's symbol
- uom
UnitOfMeasure[A]
- Definition Classes
- Quantity
-
def
toTuple: (Double, String)
Returns a tuple representing the numeric value and the unit's symbol
Returns a tuple representing the numeric value and the unit's symbol
- Definition Classes
- Quantity
-
def
unary_-: Temperature
- Definition Classes
- Quantity
-
val
unit: TemperatureScale
The Unit of Measure the value represents
The Unit of Measure the value represents
- returns
UnitOfMeasure[A]
- Definition Classes
- Temperature → Quantity
-
val
value: Double
The value of the quantity given the unit
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... ) @native()
-
def
within(range: QuantityRange[Temperature]): Boolean
Returns true if this value is within (contains) the range
Returns true if this value is within (contains) the range
- range
QuantityRange
- returns
Boolean
- Definition Classes
- Quantity
-
def
~=(that: Temperature)(implicit tolerance: Temperature): Boolean
approx
approx
- Definition Classes
- Quantity
-
def
≈(that: Temperature)(implicit tolerance: Temperature): Boolean
approx
approx
- Definition Classes
- Quantity