CARVIEW |
Select Language
HTTP/2 200
date: Sat, 11 Oct 2025 04:18:02 GMT
content-type: text/html; charset=UTF-8
server: cloudflare
x-frame-options: DENY
x-content-type-options: nosniff
x-xss-protection: 1;mode=block
vary: accept-encoding
cf-cache-status: DYNAMIC
content-encoding: gzip
set-cookie: _csrf-frontend=50f0ea8c08574092cd27a47b53cb9930dcb3ff3d18db587a0db12fcef4fbb515a%3A2%3A%7Bi%3A0%3Bs%3A14%3A%22_csrf-frontend%22%3Bi%3A1%3Bs%3A32%3A%22i8f7UZhGaT3IqstzUPXahUJhlPWD8mzJ%22%3B%7D; HttpOnly; Path=/
cf-ray: 98cb8d19dff41ec2-BLR
Scala3 UByte - Pastebin.com
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package smallui
- import scala.util.FromDigits
- import scala.util.FromDigits.*
- object UByte:
- opaque type UByte = Byte
- // Code to support custom number literals for UByte.
- // Unfortunately, custom number literals aren't working in Scala prior to 3.2.2 at the moment of writing
- given FromDigits[UByte] = literal =>
- if literal.isBlank || literal.length > 4
- then throw MalformedNumber()
- val firstChar = literal.charAt(0)
- val firstDigit = firstChar.isDigit
- if !(firstDigit || firstChar == '+') then throw MalformedNumber()
- else if firstChar == '-' then throw NumberTooSmall()
- var int = if firstDigit then firstChar.toInt else 0
- var i = 1
- while i < literal.length do
- val char = literal.charAt(i)
- if char.isDigit
- then int = int * 10 + char.toInt
- else throw MalformedNumber()
- i += 1
- end while
- if int > 255 then throw NumberTooLarge()
- (int - 128).toByte
- end given
- extension (self: UByte) {
- inline def -(other: UByte): UByte =
- (self - other).toByte
- inline def +(other: UByte): UByte =
- (self + other).toByte
- inline def /(other: UByte): UByte =
- (self / other).toByte
- inline def *(other: UByte): UByte =
- (self * other).toByte
- inline def toString: String =
- (self + 128).toString
- }
- extension (self: String)
- inline def toUByte: UByte = summon[FromDigits[UByte]].fromDigits(self)
- extension (self: Byte)
- inline def toUByte: UByte = self
- extension (self: Char)
- inline def toUByte: UByte = self.toByte
- extension (self: Short)
- inline def toUByte: UByte = (self - 128).toByte
- extension (self: Int)
- inline def toUByte: UByte = (self - 128).toByte
- extension (self: Long)
- inline def toUByte: UByte = (self - 128).toByte
- extension (self: Float)
- inline def toUByte: UByte = (self - 128).toByte
- extension (self: Double)
- inline def toUByte: UByte = (self - 128).toByte
- export UByte.UByte
Advertisement
Add Comment
Please, Sign In to add comment
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 11 sec ago | 0.10 KB
-
⭐⭐⭐GMAIL Logs (2FA disabled)⭐⭐
Java | 23 sec ago | 0.10 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 39 sec ago | 0.10 KB
-
⭐⭐⭐MAKE $500 IN 15 MIN⭐⭐
Java | 51 sec ago | 0.10 KB
-
⭐⭐⭐Free Giftcards Method⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Instant Profit Method⭐⭐
Java | 1 min ago | 0.10 KB
-
⭐⭐⭐Make $1500 in 20 minutes⭐⭐
Java | 1 min ago | 0.10 KB
-
✅⭐ Make huge profits on trading ⭐⭐ D
JavaScript | 3 min ago | 0.24 KB
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand