-
-
Notifications
You must be signed in to change notification settings - Fork 1
units
It is not clear whether units should be implemented.
The SI system uses a quantity, a prefix, and a dimension. The first is a number, the second is a letter, an the last is a product of base units (The International System of Units (SI))
dim Q = LαMβTγIδΘεNζJη
- Lα – length and power
- Mβ – mass and power
- Tγ – time and power
- Iδ – electric current and power
- Θε – thermodynamic temperature and power
- Nζ – amount of substance and power
- Jη – luminous intensity and power
Specific sets of base units has their own names, such that Volt (V) is kg·m²·s⁻³·A⁻¹ and that weight is kilogram (kg). The last one is defined with a prefix. Some units can be a bit surprising, such as siemens (S) which is defined as Ω⁻¹ or kg⁻¹⋅m⁻²⋅s³⋅A².
When a value has units, they may be derived units which would be unpacked, or base units that are used as-is. They are extracted to a map before further actions, where each base unit is accumulated for itself.
If units are different during addition and subtraction, then the result will be a NaN.
If the operation is multiplication, then the powers will be added to the accumulators.
If the operation is division or modulus, then the powers from the divisor will be subtracted from the dividend.
Non SI units will be converted into SI units before processing, and then converted back into the same system if possible. Not being able to convert it back is not an error, but the units will then stay as SI units.
Units are the last string of chars in the value, and should have a leading space (?)