Other functions
Error handling · Floating point · Quantities · Chemical elements · Mixed unit conversion · Temperature conversion · Color format conversion
Error handling
Defined in: core::error
error
Throw an error with the specified message. Stops the execution of the program.
Floating point
Defined in: core::numbers
is_nan
Returns true if the input is NaN.
More information here.
is_infinite
Returns true if the input is positive infinity or negative infinity. More information here.
is_finite
Returns true if the input is neither infinite nor NaN.
is_zero
Returns true if the input is 0 (zero).
is_nonzero
Returns true unless the input is 0 (zero).
is_integer
Returns true if the input is an integer.
Quantities
Defined in: core::quantities
value_of
Extract the plain value of a quantity (the 20 in 20 km/h). This can be useful in generic code, but should generally be avoided otherwise.
unit_of
Extract the unit of a quantity (the km/h in 20 km/h). This can be useful in generic code, but should generally be avoided otherwise. Returns an error if the quantity is zero.
has_unit
Returns true if quantity has the same unit as unit_query, or if quantity evaluates to zero.
is_dimensionless
Returns true if quantity is dimensionless, or if quantity is zero.
unit_name
Returns a string representation of the unit of quantity. Returns an empty string if quantity is dimensionless.
quantity_cast
Unsafe function that returns the quantity from unmodified with the target dimension To. This can be useful in generic code, but should generally be avoided otherwise.
Chemical elements
Defined in: chemistry::elements
element (Chemical element)
Get properties of a chemical element by its symbol or name (case-insensitive).
Get the entire element struct for hydrogen.
element("H")
= ChemicalElement { symbol: "H", name: "Hydrogen", atomic_number: 1, group: 1, group_name: "Alkali metals", period: 1, melting_point: 13.99 K, boiling_point: 20.271 K, density: 0.00008988 g/cm³, electron_affinity: 0.754 eV, ionization_energy: 13.598 eV, vaporization_heat: 0.904 kJ/mol } [ChemicalElement]
Get the ionization energy of hydrogen.
Run this exampleMixed unit conversion
Defined in: units::mixed
unit_list (Unit list)
Convert a value to a mixed representation using the provided units.
Example
Run this exampleDMS (Degrees, minutes, seconds)
Convert an angle to a mixed degrees, (arc)minutes, and (arc)seconds representation. Also called sexagesimal degree notation. More information here.
DM (Degrees, decimal minutes)
Convert an angle to a mixed degrees and decimal minutes representation. More information here.
feet_and_inches (Feet and inches)
Convert a length to a mixed feet and inches representation. More information here.
pounds_and_ounces (Pounds and ounces)
Convert a mass to a mixed pounds and ounces representation. More information here.
Temperature conversion
Defined in: physics::temperature_conversion
from_celsius
Converts from degree Celsius (°C) to Kelvin. More information here.
celsius
Converts from Kelvin to degree Celcius (°C). This can be used on the right hand side of a conversion operator: 200 K -> celsius.
More information here.
from_fahrenheit
Converts from degree Fahrenheit (°F) to Kelvin. More information here.
fahrenheit
Converts from Kelvin to degree Fahrenheit (°F). This can be used on the right hand side of a conversion operator: 200 K -> fahrenheit.
More information here.
Color format conversion
Defined in: extra::color
rgb
Create a Color from RGB (red, green, blue) values in the range \( [0, 256) \).
Example
Run this examplecolor
Create a Color from a (hexadecimal) value.
Example
Run this examplecolor_rgb
Convert a color to its RGB representation.
color_rgb_float
Convert a color to its RGB floating point representation.
Example
Run this examplecolor_hex
Convert a color to its hexadecimal representation.