Temperature

final class Temperature extends Quantity[Temperature]

Represents a quantity of 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.

Value Params
value

the value of the temperature

Authors

garyKeorkunian

Since

0.1

Companion
object
trait Ordered[Temperature]
trait Comparable[Temperature]
trait Serializable
class Object
trait Matchable
class Any

Value members

Concrete methods

def *(that: ThermalCapacity): Energy
override def minus(that: Temperature): Temperature
Definition Classes
override def plus(that: Temperature): Temperature
Definition Classes
def to(unit: TemperatureScale): Double
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
override def toString: String
Definition Classes
Quantity -> Any
def toString(unit: TemperatureScale): String

Inherited methods

def %(that: Temperature): Double
Inherited from
Quantity
def %(that: Double): Temperature
Inherited from
Quantity
def *(that: Price[Temperature]): Money
Inherited from
Quantity
def *(that: Double): Temperature
Inherited from
Quantity
Inherited from
Quantity
Inherited from
Quantity
Inherited from
Quantity
def /(that: Temperature): Double
Inherited from
Quantity
def /(that: Double): Temperature
Inherited from
Quantity
def /%(that: Temperature): (Double, Temperature)
Inherited from
Quantity
def /%(that: Double): (Temperature, Temperature)
Inherited from
Quantity
def <(that: Temperature): Boolean
Inherited from
Ordered
def <=(that: Temperature): Boolean
Inherited from
Ordered
def =~(that: Temperature)(tolerance: Temperature): Boolean

approx

approx

Inherited from
Quantity
def >(that: Temperature): Boolean
Inherited from
Ordered
def >=(that: Temperature): Boolean
Inherited from
Ordered

Returns the absolute value of this Quantity

Returns the absolute value of this Quantity

Returns

Quantity

Inherited from
Quantity
def approx(that: Temperature)(tolerance: Temperature): Boolean

Returns boolean result of approximate equality comparison

Returns boolean result of approximate equality comparison

Value Params
that

Quantity

tolerance

Quantity

Inherited from
Quantity

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

See also

java.lang.Math#ceil(double)

Inherited from
Quantity
def compare(that: Temperature): Int

Implements Ordered.compare

Implements Ordered.compare

Value Params
that

Quantity

Returns

Int

Inherited from
Quantity
def compareTo(that: Temperature): Int
Inherited from
Ordered
def divide(that: Temperature): Double

Divide this quantity by a like quantity

Divide this quantity by a like quantity

Value Params
that

Quantity

Returns

Double

Inherited from
Quantity
def divide(that: Double): Temperature

Divide this quantity by some number

Divide this quantity by some number

Value Params
that

Double

Returns

Quantity

Inherited from
Quantity

Returns a Pair that includes the result of divideToInteger and remainder

Returns a Pair that includes the result of divideToInteger and remainder

Value Params
that

Quantity

Returns

(Double, Quantity)

Inherited from
Quantity

Returns a Pair that includes the result of divideToInteger and remainder

Returns a Pair that includes the result of divideToInteger and remainder

Value Params
that

Double

Returns

(Quantity, Quantity)

Inherited from
Quantity
override def equals(that: Any): Boolean

Override of equals method

Override of equals method

Value Params
that

must be of matching value and unit

Definition Classes
Quantity -> Any
Inherited from
Quantity

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

See also

java.lang.Math#floor(double)

Inherited from
Quantity
override def hashCode(): Int

Override of hashCode

Override of hashCode

Definition Classes
Quantity -> Any
Inherited from
Quantity

Returns an equivalent Quantity boxed with the supplied Unit

Returns an equivalent Quantity boxed with the supplied Unit

Value Params
uom

UnitOfMeasure[A]

Returns

Quantity

Inherited from
Quantity
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

Value Params
f

Double => Double function

Inherited from
Quantity

Returns the max of this and that Quantity

Returns the max of this and that Quantity

Value Params
that

Quantity

Returns

Quantity

Inherited from
Quantity

Returns the min of this and that Quantity

Returns the min of this and that Quantity

Value Params
that

Quantity

Returns

Quantity

Inherited from
Quantity

Returns the negative value of this Quantity

Returns the negative value of this Quantity

Returns

Quantity

Inherited from
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

Value Params
range

QuantityRange

Returns

Boolean

Inherited from
Quantity

Returns a QuantityRange representing the range for this value +- that

Returns a QuantityRange representing the range for this value +- that

Value Params
that

Quantity

Returns

QuantityRange

Inherited from
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

Value Params
that

Quantity

Returns

Double

Inherited from
Quantity
def remainder(that: Double): Temperature

Returns the remainder of a division by a number

Returns the remainder of a division by a number

Value Params
that

Quantity

Returns

Quantity

Inherited from
Quantity

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

See also

java.lang.Math#rint(double)

Inherited from
Quantity
def rounded(scale: Int, mode: RoundingMode): Temperature

Returns the Quantity with its coefficient value rounded using scale and mode. The unit is maintained.

Returns the Quantity with its coefficient value rounded using scale and mode. The unit is maintained.

Value Params
mode

RoundingMode - defaults to HALF_EVEN

scale

Int - scale of the value to be returned

Returns

Quantity

Inherited from
Quantity
def times(that: Double): Temperature

Multiply this quantity by some number

Multiply this quantity by some number

Value Params
that

Double

Returns

Quantity

Inherited from
Quantity
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)
Value Params
uom

UnitOfMeasure[A]

Returns

Double

Inherited from
Quantity

Returns a QuantityRange that goes from this to that

Returns a QuantityRange that goes from this to that

Value Params
that

Quantity

Returns

QuantityRange

Inherited from
Quantity
def toString(uom: UnitOfMeasure[Temperature], format: String): String

Returns a string representing the quantity's value in the given unit in the given format

Returns a string representing the quantity's value in the given unit in the given format

Value Params
format

String containing the format for the value (ie "%.3f")

uom

UnitOfMeasure[A] with UnitConverter

Returns

String

Inherited from
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

Value Params
uom

UnitOfMeasure[A] with UnitConverter

Returns

String

Inherited from
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

Value Params
uom

UnitOfMeasure[A]

Inherited from
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

Inherited from
Quantity
Inherited from
Quantity
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

Value Params
range

QuantityRange

Returns

Boolean

Inherited from
Quantity
def ~=(that: Temperature)(tolerance: Temperature): Boolean

approx

approx

Inherited from
Quantity
def (that: Temperature)(tolerance: Temperature): Boolean

approx

approx

Inherited from
Quantity

Concrete fields

val value: Double