LanguageValues and typesStandard typesPhysical quantities
TemperatureDifference
On this page
The gap between two temperatures, so 5 °C warmer isn't the same as 5 °C.
Use it for "raise by 5 degrees". A Temperature minus a Temperature gives one, and units.of makes one from a number.
Shape
One value, with no fields to fill in. As text it reads 5 kelvin.
Example
var warmer: TemperatureDifference = 26degC - 21degCassert warmer == units.of(5, TemperatureDifferenceUnit.kelvin)
text.parse(raw, as: TemperatureDifference) reads one from text that comes from outside. Text that isn't one at all fails malformed, such as 5, 1.2.3 or five.
These operations give one: units.of and units.sum.
Good to know
- It is held in kelvin to 3 places.
==tells you whether two are the same, and<andlist.sort_bycompare and sort them.
In JSON
An object of its parts, in a request, a response or json.write:
{"value":"-5","unit":"kelvin"}{"value":"0","unit":"kelvin"}{"value":"5","unit":"kelvin"}
Details
Text form, storage, how it is shown, and operations
TemperatureDifference is in the group Physical quantities, and has been in Jadpo since 0.1.0.
Text form
text.from writes one standard text form, the same form text.parse reads back: -5 kelvin, 0 kelvin and 5 kelvin.
How it is stored
It is stored in one column named for the field, of type numeric(38, 3), holding the temperatureDifference in kelvins (K). 0 kelvin is stored as 0.
How it is shown to people
text.format(value, locale:) shows it to people in their locale. A call may also give unit:.
With locale: Locale.en_gb:
| Value | Shown |
|---|---|
-5 kelvin |
-5 K |
0 kelvin |
0 K |
5 kelvin |
5 K |
Operations
units.in(value: Quantity, unit: QuantityUnit, scale: Int, rounding: Rounding) -> Decimal:valueinunit, a unit of its kind, as aDecimalofscaleplaces rounded byrounding:units.in(5km, LengthUnit.mile, scale: 2, rounding: Rounding.half_even)is3.11.units.of(value: Number, unit: QuantityUnit) -> Quantity:valueofunit, anIntor aDecimal, as the quantity ofunit's kind, converted exactly to the base unit and rounded half to even to the kind's scale:units.of(5, LengthUnit.mile).units.sum(items: List<Quantity>) -> Quantity: The items added up, all of one kind; nothing for no items. ATemperatureor aSoundLeveldoesn't add to itself, so neither is summed.
It also takes text.parse, text.from, text.format, json.read, json.write and ==. How every standard type behaves says how they work.
Markdown for agents: /docs/types/type-temperature-difference.md.Built from Jadpo main at aee2e8f.