Import std.math.units
std.math.units
Typed units: a Quantity is a value in SI's base units, meters, kilograms, and seconds, with the
exponents of its length, mass, and time as Const type arguments, so the compiler keeps Meters
apart from Seconds and works out what Meters / Seconds is. Each unit is an Alias of its
Quantity: Meters is Quantity<1, 0, 0>, and MetersPerSecond Quantity<1, 0, -1>. + and - take
quantities of the same units, * and / any two, adding or taking away their exponents, and a
Double scales one.
std/math/units.fb
Types
Quantity
struct
Public Struct Quantity<Const L: Int, Const M: Int, Const T: Int> Implements Comparable, Hashable, Printable, Defaultable
A value of so many meters, kilograms, and seconds, to the powers L, M, and T: 5 m/s^2 is a
Quantity<1, 0, -2> of Value 5.
-
The value in the base units, and the units they make.
-
A quantity of 0 of these units.
-
The value to start from, like 0 for a number, "" for a String, or an empty collection.
-
The value and its units, as SI writes them: "9.8 m/s^2", "3 kg m/s^2", "50 1/s", or "4 kg/(m s^2)", and the value alone without any.
-
aplusb. -
aminusb. -
anegated. -
atimesscale. -
scaletimesa. -
adivided byscale. -
Operator *<Const L2: Int, Const M2: Int, Const T2: Int>(a: Quantity<L, M, T>, b: Quantity<L2, M2, T2>): Quantity<L + L2, M + M2, T + T2>operator #atimesb, whose exponents are the sum ofa's andb's. -
Operator /<Const L2: Int, Const M2: Int, Const T2: Int>(a: Quantity<L, M, T>, b: Quantity<L2, M2, T2>): Quantity<L - L2, M - M2, T - T2>operator #adivided byb, whose exponents are the difference ofa's andb's. -
Whether
acomes beforeb.Doc from
std.core.interfaces.Comparable.Operator<.
Meters
alias
Public Alias Meters = Quantity<1, 0, 0>
The base units, and those made from them.
Kilograms
alias
Public Alias Kilograms = Quantity<0, 1, 0>
Kilograms, of mass.
Seconds
alias
Public Alias Seconds = Quantity<0, 0, 1>
Seconds, of time.
SquareMeters
alias
Public Alias SquareMeters = Quantity<2, 0, 0>
Square meters, of area.
CubicMeters
alias
Public Alias CubicMeters = Quantity<3, 0, 0>
Cubic meters, of volume.
MetersPerSecond
alias
Public Alias MetersPerSecond = Quantity<1, 0, -1>
Meters per second, of speed.
MetersPerSecondSquared
alias
Public Alias MetersPerSecondSquared = Quantity<1, 0, -2>
Meters per second squared, of acceleration.
Hertz
alias
Public Alias Hertz = Quantity<0, 0, -1>
Hertz, a time each second, of frequency.
Newtons
alias
Public Alias Newtons = Quantity<1, 1, -2>
Newtons, of force.
NewtonSeconds
alias
Public Alias NewtonSeconds = Quantity<1, 1, -1>
Newton seconds, of momentum.
Joules
alias
Public Alias Joules = Quantity<2, 1, -2>
Joules, of energy.
Watts
alias
Public Alias Watts = Quantity<2, 1, -3>
Watts, of power.
Pascals
alias
Public Alias Pascals = Quantity<-1, 1, -2>
Pascals, of pressure.
KilogramsPerCubicMeter
alias
Public Alias KilogramsPerCubicMeter = Quantity<-3, 1, 0>
Kilograms per cubic meter, of density.
Functions
Abs
function
Public Function Abs<Const L: Int, Const M: Int, Const T: Int>(q: Quantity<L, M, T>): Quantity<L, M, T>
How big a quantity is, of the same units, as the scalar Abs has it: 0 for -0.
Kilometers
function
Public Function Kilometers(value: Double): Meters
Other units, as the base units' quantities.
Centimeters
function
Public Function Centimeters(value: Double): Meters
The meters of value centimeters.
Millimeters
function
Public Function Millimeters(value: Double): Meters
The meters of value millimeters.
Grams
function
Public Function Grams(value: Double): Kilograms
The kilograms of value grams.
Tonnes
function
Public Function Tonnes(value: Double): Kilograms
The kilograms of value tonnes.
Milliseconds
function
Public Function Milliseconds(value: Double): Seconds
The seconds of value milliseconds.
Minutes
function
Public Function Minutes(value: Double): Seconds
The seconds of value minutes.
Hours
function
Public Function Hours(value: Double): Seconds
The seconds of value hours.
KilometersPerHour
function
Public Function KilometersPerHour(value: Double): MetersPerSecond
The meters per second of value kilometers per hour.
Report an issue with this page or with FutureBlitz on GitHub.