Temperature

Immutable measurement of temperature.

This class represents temperature values in Celsius, Fahrenheit, or Kelvin. It supports arithmetic operations and conversions between different temperature units.

Properties

Link copied to clipboard

Absolute value of measure.

Link copied to clipboard

A convenience method to get the base unit of the measurement. Equivalent to unit.baseUnit.

Link copied to clipboard
open override val baseUnitMagnitude: Double

Gets the magnitude of this measure in terms of the base unit. If the unit is the base unit for its system of measure, then the value will be equivalent to magnitude.

Link copied to clipboard
open override val magnitude: Double

Gets the unitless magnitude of this measure.

Link copied to clipboard
open val sign: Double

Returns the sign of this measure.

Link copied to clipboard
open override val unit: TemperatureUnit

Gets the units of this measure.

Functions

Link copied to clipboard
open fun abs(unit: TemperatureUnit): Double

Absolute value of measure.

Link copied to clipboard
open operator override fun compareTo(other: Measure<TemperatureUnit>): Int
Link copied to clipboard
open fun div(other: Measure<out TemperatureUnit>): Double

Divides this measure by another measure and returns the ratio as a dimensionless value.

open operator fun <V : Unit<V>> div(other: Measure<V>): Per<TemperatureUnit, V>

Divides this measure by another measure of a different type to create a ratio unit. For example, Distance / Time creates a velocity measurement, or Voltage / Distance creates electric field strength.

open operator fun div(divisor: Number): Measure<TemperatureUnit>
open operator override fun div(divisor: Double): Temperature

Divides this measure by a scalar and returns the result.

Link copied to clipboard
open fun into(unit: TemperatureUnit): Double

Converts this measure to a measure with a different unit of the same type, eg minutes to seconds. Converting to the same unit is equivalent to calling magnitude.

Link copied to clipboard
open fun isEquivalent(other: Measure<*>): Boolean

Checks if this measure is equivalent to another measure of the same unit.

Link copied to clipboard
open fun isNear(other: Measure<*>, varianceThreshold: Double): Boolean

Checks if this measure is near another measure of the same unit. Provide a variance threshold for use for a +/- scalar, such as 0.05 for +/- 5%.

Checks if this measure is near another measure of the same unit, with a specified tolerance of the same unit.

Link copied to clipboard
open operator override fun minus(other: Measure<out TemperatureUnit>): Temperature

Subtracts another measure of the same unit type from this one.

Link copied to clipboard

Returns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code like Celsius.of(10).negate() returns a value equivalent to -10 Kelvin, and not -10° Celsius.

Link copied to clipboard
open operator override fun plus(other: Measure<out TemperatureUnit>): Temperature

Adds another measure of the same unit type to this one.

Link copied to clipboard
open operator fun <V : Unit<V>> times(other: Measure<V>): Mul<TemperatureUnit, V>

Multiplies this measure by another measure of a different type to create a compound unit. For example, Distance * Distance creates an area measurement, or Voltage * Time creates charge.

open operator fun times(multiplier: Number): Measure<TemperatureUnit>
open operator override fun times(multiplier: Double): Temperature

Multiplies this measure by a scalar unitless multiplier.

Link copied to clipboard
open fun toLongString(): String

Returns a string representation of this measurement in a longhand form. The name of the backing unit is used, rather than its symbol, and the magnitude is represented in a full string, not scientific notation. (Very large values may be represented in scientific notation, however)

Link copied to clipboard
open fun toShortString(): String

Returns a string representation of this measurement in a shorthand form. The symbol of the backing unit is used, rather than the full name, and the magnitude is represented in scientific notation.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open operator override fun unaryMinus(): Temperature

Returns a measure equivalent to this one equal to zero minus its current value. For non-linear unit types like temperature, the zero point is treated as the zero value of the base unit (eg Kelvin). In effect, this means code like Celsius.of(10).unaryMinus() returns a value equivalent to -10 Kelvin, and not -10° Celsius.

Link copied to clipboard

Take the sign of another measure. This measure's and the provided measure's signs are considered in this measure's unit.

Take the sign of another measure.