Library providing Kotlin extensions and ease of use functions for Java Units of Measurement libraries.
- Core - Basic Metric units.
- SI-Units - SI units.
- Complete-Units - All units including imperial.
val small = 10.metre
val large = 10.kilo.metre
val added = 10.metre + 1.kilo.metre
>> 1010.0 m
val speed = added/10.minute
>> 101 m/min
var aFewSeconds = 5.second
aFewSeconds++
>> 6.0 s
10.peta.watt > 2.watt
>> true
5.gram <= 20.kilo.gram
>> true
(-10.nano.metre).abs()
>> 10.0 nm
## The operator '==' does not always work reliably for quantities;
## the function qeq() should be used instead.
1.kilo.gram == 1000.gram
>> false
1.kilo.gram qeq 1000.gram
>> true
5.gram + 2.pound
>> 912.18474 g
(13.kilo.gram + 20.pound) convertTo STONE
>> 3.47572100600243466674378 st
Currently all quantities are reference types, so heavy usage of this library will involve some level of extraneous object creation. Hopefully we can resolve this issue with project valhalla or another attempt to get value types in the JVM.