Import std.math.units
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.
Examples
Local distance = Kilometers(3)
Local time = Minutes(10)
Local speed: MetersPerSecond = distance / time
Expect(IsClose(speed.Value, 5.0))
Local total: Meters = distance + Meters(500)
Expect(total.Value == 3500.0)
// distance + time doesn't compile: they're different units.-
The value in the base units, and the units they make.
-
A quantity of 0 of these units.
-
Zero, in its units.
-
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
ais less thanb, in the same units.
Report an issue with this page or with FutureBlitz on GitHub.