Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions library/api/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ package me.saket.bytesize {
}

public final class ByteSizeKt {
method public static inline me.saket.bytesize.ByteSize getAbsoluteValue(me.saket.bytesize.ByteSize);
method public static inline operator me.saket.bytesize.ByteSize times(Number, me.saket.bytesize.ByteSize other);
method public static inline long toBinaryBytes(me.saket.bytesize.ByteSize);
method public static inline long toDecimalBits(me.saket.bytesize.ByteSize);
Expand Down
8 changes: 8 additions & 0 deletions library/src/commonMain/kotlin/me/saket/bytesize/ByteSize.kt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,11 @@ inline fun ByteSize.toDecimalBytes(): DecimalByteSize =

inline fun ByteSize.toDecimalBits(): DecimalBitSize =
this as? DecimalBitSize ?: DecimalBitSize(this.inWholeBytes * BitsPerByte)

inline val ByteSize.absoluteValue: ByteSize
get() =
when (this) {
is DecimalBitSize -> absoluteValue
is BinaryByteSize -> absoluteValue
is DecimalByteSize -> absoluteValue
}
Loading