in daffodil-lib/src/main/scala/passera/unsigned/ULong.scala [37:141]
def toUByte = UByte((rep & 0xffffffffL).toByte)
def toUShort = UShort((rep & 0xffffffffL).toShort)
def toUInt = UInt((rep & 0xffffffffL).toInt)
def toULong = this
override def toByte: Byte = (rep & 0x7fffffffffffffffL).toByte
override def toChar: Char = (rep & 0x7fffffffffffffffL).toChar
override def toShort: Short = (rep & 0x7fffffffffffffffL).toShort
override def toInt: Int = (rep & 0x7fffffffffffffffL).toInt
override def toLong: Long = rep
override def toFloat: Float = (rep & 0x7fffffffffffffffL).toFloat
override def toDouble: Double = (rep >>> 1).toDouble * 2.0 + (rep & 1L)
def toBigInt: JBigInt =
if (rep >= 0) JBigInt.valueOf(rep)
else JBigInt.valueOf(rep).and(ULong.MaxValueAsBigInt)
// override def intValue = rep
override def byteValue = toByte
override def shortValue = toShort
override def intValue = toInt
override def floatValue = toFloat
override def doubleValue = toDouble
def +(x: Int)(implicit d: DummyImplicit): Long = this.toLong + x
def -(x: Int)(implicit d: DummyImplicit): Long = this.toLong - x
def *(x: Int)(implicit d: DummyImplicit): Long = this.toLong * x
def /(x: Int)(implicit d: DummyImplicit): Long = this.toLong / x
def %(x: Int)(implicit d: DummyImplicit): Long = this.toLong % x
def &(x: Int)(implicit d: DummyImplicit): Long = this.toLong & x
def ^(x: Int)(implicit d: DummyImplicit): Long = this.toLong ^ x
def |(x: Int)(implicit d: DummyImplicit): Long = this.toLong | x
def +(x: Long)(implicit d: DummyImplicit): Long = this.toLong + x
def -(x: Long)(implicit d: DummyImplicit): Long = this.toLong - x
def *(x: Long)(implicit d: DummyImplicit): Long = this.toLong * x
def /(x: Long)(implicit d: DummyImplicit): Long = this.toLong / x
def %(x: Long)(implicit d: DummyImplicit): Long = this.toLong % x
def &(x: Long)(implicit d: DummyImplicit): Long = this.toLong & x
def ^(x: Long)(implicit d: DummyImplicit): Long = this.toLong ^ x
def |(x: Long)(implicit d: DummyImplicit): Long = this.toLong | x
def +(x: UByte): ULong = this + x.toULong
def -(x: UByte): ULong = this - x.toULong
def *(x: UByte): ULong = this * x.toULong
def /(x: UByte): ULong = this / x.toULong
def %(x: UByte): ULong = this % x.toULong
def &(x: UByte): ULong = this & x.toULong
def ^(x: UByte): ULong = this ^ x.toULong
def |(x: UByte): ULong = this | x.toULong
def <(x: UByte): Boolean = this < x.toULong
def >(x: UByte): Boolean = this > x.toULong
def <=(x: UByte): Boolean = this <= x.toULong
def >=(x: UByte): Boolean = this >= x.toULong
def +(x: UShort): ULong = this + x.toULong
def -(x: UShort): ULong = this - x.toULong
def *(x: UShort): ULong = this * x.toULong
def /(x: UShort): ULong = this / x.toULong
def %(x: UShort): ULong = this % x.toULong
def &(x: UShort): ULong = this & x.toULong
def ^(x: UShort): ULong = this ^ x.toULong
def |(x: UShort): ULong = this | x.toULong
def <(x: UShort): Boolean = this < x.toULong
def >(x: UShort): Boolean = this > x.toULong
def <=(x: UShort): Boolean = this <= x.toULong
def >=(x: UShort): Boolean = this >= x.toULong
def +(x: UInt): ULong = this + x.toULong
def -(x: UInt): ULong = this - x.toULong
def *(x: UInt): ULong = this * x.toULong
def /(x: UInt): ULong = this / x.toULong
def %(x: UInt): ULong = this % x.toULong
def &(x: UInt): ULong = this & x.toULong
def ^(x: UInt): ULong = this ^ x.toULong
def |(x: UInt): ULong = this | x.toULong
def <(x: UInt): Boolean = this < x.toULong
def >(x: UInt): Boolean = this > x.toULong
def <=(x: UInt): Boolean = this <= x.toULong
def >=(x: UInt): Boolean = this >= x.toULong
def +(x: ULong): ULong = ULong(rep + x.rep)
def -(x: ULong): ULong = ULong(rep - x.rep)
def *(x: ULong): ULong = ULong(rep * x.rep)
private def rot(x: Long) = (x + Long.MinValue)
def /(x: ULong): ULong = {
val n = rep
val d = x.rep
if (d < 0) {
if (this < x)
ULong(0L)
else
ULong(1L)
} else {
val q = ((n >>> 1) / d) << 1
val r = n - q * d
if (ULong(r) >= x)
ULong(q + 1)
else
ULong(q)
}
}