Temperature class final

A quantity representing temperature.

Unlike most quantities, temperature conversions involve both a scale factor and a zero-point offset (e.g. Celsius and Fahrenheit share a 9:5 ratio but differ by 32° at zero). This class handles both:

  • Scale conversions (toFahrenheit, toCelsius, etc.) adjust for the zero-point offset and are appropriate when converting thermometer readings.
  • Degree conversions (toFahrenheitDegrees, toCelsiusDegrees, etc.) skip the offset and are appropriate when converting a difference between two temperatures (e.g. "5 Celsius degrees warmer").

Arithmetic (+, -) operates on degree magnitudes without offset adjustment so that 37°C + 1°C == 38°C rather than trying to account for absolute zero.

Inheritance

Constructors

Temperature(double value, UnitOfMeasure<Temperature> unit)

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toCelsius Temperature
Converts this temperature to the Celsius scale.
no setter
toCelsiusDegrees Temperature
Converts this temperature magnitude to Celsius degrees (no offset).
no setter
toFahrenheit Temperature
Converts this temperature to the Fahrenheit scale.
no setter
toFahrenheitDegrees Temperature
Converts this temperature magnitude to Fahrenheit degrees (no offset).
no setter
toKelvin Temperature
Converts this temperature to the Kelvin scale.
no setter
toKelvinDegrees Temperature
Converts this temperature magnitude to Kelvin degrees (no offset).
no setter
toRankine Temperature
Converts this temperature to the Rankine scale.
no setter
toRankineDegrees Temperature
Converts this temperature magnitude to Rankine degrees (no offset).
no setter
unit UnitOfMeasure<Temperature>
The unit of measure that value is expressed in.
finalinherited
value double
The raw numeric value of this quantity expressed in unit.
finalinherited

Methods

equivalentTo(Quantity<Temperature> other) bool
Returns true if this quantity represents the same physical magnitude as other, regardless of which unit each is expressed in.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
to(UnitOfMeasure<Temperature> uom) double
Converts this quantity to uom and returns the raw double value.
override
toString() String
A string representation of this object.
override

Operators

operator +(Temperature that) Temperature
Returns the sum of degree magnitudes in the units of this Temperature.
override
operator -(Temperature that) Temperature
Returns the difference of degree magnitudes in the units of this Temperature.
override
operator <(Temperature that) bool
Returns true if this quantity is less than that.
inherited
operator <=(Temperature that) bool
Returns true if this quantity is less than or equal to that.
inherited
operator ==(Object other) bool
The equality operator.
inherited
operator >(Temperature that) bool
Returns true if this quantity is greater than that.
inherited
operator >=(Temperature that) bool
Returns true if this quantity is greater than or equal to that.
inherited

Static Methods

parse(String s) → Option<Temperature>
Parses s into a Temperature, returning None if parsing fails.
override

Constants

celsius → const Celsius
Unit for degrees Celsius (°C).
fahrenheit → const Fahrenheit
Unit for degrees Fahrenheit (°F).
kelvin → const Kelvin
Unit for Kelvin (K).
rankine → const Rankine
Unit for degrees Rankine (°R).
units → const Set<TemperatureScale>
All supported Temperature units.