As a super-class of numbers, Kawa also provides quantities. A quantity is a product of a unit and a pure number. The number part can be an arbitrary complex number. The unit is a product of integer powers of base units, such as meter or second.
Kawa quantities are a generalization of the quantities in DSSSL, which only has length-derived quantities.
The precise syntax of quantity literals may change,
but some examples are 10pt
(10 points), 5s
(5 seconds),
and 4cm^2
(4 square centimeters).
True iff
object
is a quantity. Note that all numbers are quantities, but not the other way round. Currently, there are no quantities that re not numbers. To distinguish a plain unit-less number from a quantity, you can usecomplex?
.
Returns the pure number part of the quantity
q
, relative to primitive (base) units. Ifq
is a number, returnsq
. Ifq
is a unit, yields the magitude ofq
relative to base units.
Returns the unit of the quantity
q
. Ifq
is a number, returns the empty unit.
Function: make-quantity
x
unit
Returns the product of
x
(a pure number) andunit
. You can specify a string instead ofunit
, such as"cm"
or"s"
(seconds).