Skip to content

Pure Kotlin utilities for converting numbers to raw bytes.

License

Notifications You must be signed in to change notification settings

k-libs/number-serialization

Repository files navigation

Number Serialization

number serialization docs dokka ff69b4 number serialization

Pure Kotlin mixin/extension functions for converting numbers to raw bytes in the form of ByteArrays or UByteArrays.

Import

  implementation("io.k-libs:number-serialization:0.1.0")

Usage

Kotlin
// Get a ByteArray of the bytes that make up the target number value.
val bytes = 42.getBytes()

// Get a UByteArray of the bytes that make up the target number value.
val ubytes = 69.getUBytes()

// Write the bytes that make up a number into a given buffer.
val byteBuffer = ByteArray(4)
420.getBytes(buffer = byteBuffer, offset = 0)

// Write the ubytes that make up a number into a given buffer.
val ubyteBuffer = UByteArray(4)
666.getUBytes(buffer = ubyteBuffer)

Version History

Version Docs Description

v0.1.0

Dokka

Initial release. Contains conversion methods for signed and unsigned integral types.

About

Pure Kotlin utilities for converting numbers to raw bytes.

Resources

License

Stars

Watchers

Forks

Languages