kotlin-unsigned icon indicating copy to clipboard operation
kotlin-unsigned copied to clipboard

unsigned support for Kotlin via boxed types and unsigned operators

kotlin-unsigned

Build Status license Release Size Github All Releases

Unsigned operators and boxed types (Ubyte, Uint, Ulong and Ushort) for unsigned support.

To have a quick idea what this library offers, take a look at the tests

Differences with kotlin stdlib:

  • this project uses classes instead inline classes. To address this in critical scenarios where allocations may have a sensitive impact, primitive variable holding the utype value is a var, so you can re-use the same istance over and over again
  • utypes extend Number abstract class
  • automatic conversions
  • it is possible to string format by calling the corresponding format() method, eg: ubyte.format("%08x")
  • all the utypes implement all the function, including shl and shr for Ubyte and Ushort
  • if you add an Ushort to another Ushort you get an Ushort (and not an Uint)

Install:

With Gradle kx.util plugin, everything is nicely aligned and the boilerplate code is gone

plugins {
    id("kx.util") version "0.7.3+51"
}

dependencies {
    implementation(unsigned)
}
dependencies {
    implementation("kotlin.graphics:unsigned:3.3.1")
}

Be sure to have mary repository:

repositories {
   maven("https://raw.githubusercontent.com/kotlin-graphics/mary/master")
}

You can find all the instructions by mary

Contributions:

Don't hesitate to contribute to the project by submitting issues or pull requests for bugs and features. Any feedback is welcome at [email protected].

Credits:

Deploys by Netlify