Skip to content

Kotlin multiplatform units for representing SI and IEC bytes and bits, inspired by jakewharton/byteunits and kotlin.time.Duration

License

Notifications You must be signed in to change notification settings

saket/byte-size

Repository files navigation

byte-size

implementation "me.saket.bytesize:bytesize:2.0.0"
val cacheSize = 512.megabytes
println(cacheSize.toString())          // "512 MB"
println(cacheSize.inWholeBytes)        // "512000000"
println(cacheSize + 88_000.kilobytes)  // "600 MB"
println(cacheSize * 2)                 // "1.02 GB"
println(cacheSize < 1.gigabytes)       // "true"
val perception = 2.gibibytes
val usable = 2.gigabytes
println("${perception - usable} lost on a 2GB drive") // "140.65 MiB lost on a 2GB drive"

About

Kotlin multiplatform units for representing SI and IEC bytes and bits, inspired by jakewharton/byteunits and kotlin.time.Duration

Resources

License

Stars

Watchers

Forks

Contributors 4

  •  
  •  
  •  
  •  

Languages