Basis Unit Constants

Relative scalefactors for each built-in unit.

Context

_images/ditaa-cec989073f835607919dbe4cb7ee2cecf0fa3971.png

Introduction

Constants in the xo::qty::detail::bu namespace represent low-level building blocks for specifying units. Relative scalefactors for each unit are chosen here.

Application code will not typically use these values directtly; instead it’s expected to use units from the xo::qty::u namespace. Those units are implemented on top of the basis units described here.

#include <xo/unit/basis_unit.hpp>

using xo::qty::detail::bu;

Mass Units

group basis-unit-mass-units

Variables

constexpr basis_unit picogram = mass_unit(1, 1000000000000)
constexpr basis_unit nanogram = mass_unit(1, 1000000000)
constexpr basis_unit microgram = mass_unit(1, 1000000)
constexpr basis_unit milligram = mass_unit(1, 1000)
constexpr basis_unit gram = mass_unit(1, 1)
constexpr basis_unit kilogram = mass_unit(1000, 1)
constexpr basis_unit tonne = mass_unit(1000000, 1)
constexpr basis_unit kilotonne = mass_unit(1000000000, 1)
constexpr basis_unit megatonne = mass_unit(1000000000000, 1)
constexpr basis_unit gigatonne = mass_unit(1000000000000000, 1)

Distance Units

group basis-unit-distance-units

Variables

constexpr basis_unit picometer = distance_unit(1, 1000000000000)
constexpr basis_unit nanometer = distance_unit(1, 1000000000)
constexpr basis_unit micrometer = distance_unit(1, 1000000)
constexpr basis_unit millimeter = distance_unit(1, 1000)
constexpr basis_unit meter = distance_unit(1, 1)
constexpr basis_unit kilometer = distance_unit(1000, 1)
constexpr basis_unit megameter = distance_unit(1000000, 1)
constexpr basis_unit gigameter = distance_unit(1000000000, 1)
constexpr basis_unit lightsecond = distance_unit(299792458, 1)
constexpr basis_unit astronomicalunit = distance_unit(149597870700, 1)
constexpr basis_unit picometre = picometer
constexpr basis_unit nanometre = nanometer
constexpr basis_unit micrometre = micrometer
constexpr basis_unit millimetre = millimeter
constexpr basis_unit metre = meter
constexpr basis_unit kilometre = kilometer
constexpr basis_unit megametre = megameter
constexpr basis_unit gigametre = gigameter
constexpr basis_unit inch = distance_unit(3048, 120000)

basis-unit representing 1 inch; defined as exactly 1/12 feet

constexpr basis_unit foot = distance_unit(3048, 10000)

basis-unit representing 1 foot; defined as exactly 0.3048 meters

constexpr basis_unit yard = distance_unit(3 * 3048, 10000)

basis-unit representing 1 yard; defined as exactly 3 feet

constexpr basis_unit mile = distance_unit(5280 * 3048, 10000)

basis-unit representing 1 mile; defined as exactly 1760 yards = 5280 feet

Time Units

group basis-unit-time-units

Variables

constexpr basis_unit picosecond = time_unit(1, 1000000000000)
constexpr basis_unit nanosecond = time_unit(1, 1000000000)
constexpr basis_unit microsecond = time_unit(1, 1000000)
constexpr basis_unit millisecond = time_unit(1, 1000)
constexpr basis_unit second = time_unit(1, 1)
constexpr basis_unit minute = time_unit(60, 1)
constexpr basis_unit hour = time_unit(3600, 1)
constexpr basis_unit day = time_unit(24 * 3600, 1)
constexpr basis_unit week = time_unit(7 * 24 * 3600, 1)
constexpr basis_unit month = time_unit(30 * 24 * 3600, 1)
constexpr basis_unit year = time_unit((365 * 24 + 6) * 3600, 1)
constexpr basis_unit year365 = time_unit(365 * 24 * 3600, 1)
constexpr basis_unit year360 = time_unit(360 * 24 * 3600, 1)
constexpr basis_unit year250 = time_unit(250 * 24 * 3600, 1)