SiLib
is a Kotlin library to scale numerical values with SI
prefixes and format them with SI base units
import de.m4rv00.si.Prefix
import de.m4rv00.si.SiLib.Companion.si
import de.m4rv00.si.SiLib.Companion.unit
import de.m4rv00.si.Unit
fun main() {
100.si(Prefix.KILO) // -> 100_000
15.si(Prefix.NANO) // -> 0.000_000_015
println(1.si(Prefix.KILO).unit(Unit.METER, 3)) // -> "1.000 km"
println(1.7918.si(Prefix.MILLI).unit(Unit.SECOND, 3)) // -> "1.792 ms"
}
Distributed under the GNU General Public License v3.0 or later. See LICENSE for more information.