All Downloads are FREE. Search and download functionalities are using the official Maven repository.

me.maciejb.snappyflows.impl.Int24.scala Maven / Gradle / Ivy

The newest version!
package me.maciejb.snappyflows.impl

import akka.util.ByteString
import me.maciejb.snappyflows.impl.ByteStringParser.ByteReader


private[snappyflows] object Int24 {

  def readLE(r: ByteReader): Int = r.readByte() | r.readByte() << 8 | r.readByte() << 16
  def readLE(arr: Array[Byte]): Int = arr(0) | arr(1) << 8 | arr(2) << 16

  def writeLE(number: Int): ByteString = ByteString.apply(
    (number & 0xff).toByte,
    (number >> 8 & 0xff).toByte,
    (number >> 16 & 0xff).toByte
  )

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy