isn’t a Byte supposed to consist of eight bits?

Welcome to Scala 2.13.1 (OpenJDK 64-Bit Server VM, Java 11.0.6).
Type in expressions for evaluation. Or try :help.

scala> val b: Byte = -1
b: Byte = -1

scala> b.toBinaryString
res1: String = 11111111111111111111111111111111 
1 Like

In explicit form, that’s intWrapper(b).toBinaryString - this is a method on RichInt, operating on Int.

Is there a particular reason why we don’t warp into a RichByte with a toBinaryString method in it?

1 Like

Likely a combination of pragmatic reasons, among them that, while the RichInt method simply delegates to Java’s java.lang.Integer, there’s no such method on java.lang.Byte.