- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Byte Class Logical Operators
Wed, 2011-09-28, 05:19
Anyone know if there is a reason the bitwise logical operators of the
Byte class return an Int when the right hand is a Byte also?
Wed, 2011-09-28, 19:07
#2
Re: Byte Class Logical Operators
Odd, I've never had to convert an operation between two bytes in java to a byte because the result was an int. At any rate, doing crypto natively is really difficult. I've managed to create a bloom filter in scala, but it is not worthy of using just yet. The manipulation of bytes using bitwise operations is convoluted due to the promotion to Int.
Billy
On Sep 27, 2011, at 23:39, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
Billy
On Sep 27, 2011, at 23:39, Rex Kerr <ichoran [at] gmail [dot] com> wrote:
That's what the JVM does (and Java). Scala maintains the custom. (Probably a good idea if you think about trying to write high-performance code.)
--Rex
On Wed, Sep 28, 2011 at 12:19 AM, Billy <rossrose69 [at] gmail [dot] com (rossrose69 [at] gmail [dot] com" rel="nofollow">rossrose69 [at] gmail [dot] com)> wrote:
Anyone know if there is a reason the bitwise logical operators of the
Byte class return an Int when the right hand is a Byte also?
Wed, 2011-09-28, 20:37
#3
Re: Byte Class Logical Operators
On 2011.09.28. 20:00, Ross Rose wrote:
> Odd, I've never had to convert an operation between two bytes in java to
> a byte because the result was an int.
Maybe you were using ^=, and like operators. Those are defined to cast
back (in Java, not in Scala) to the type of the variable on left. (It
might get surprising, when you would expect an error (for example the
variable is an integral type, but the right side has a floating type),
but a silent conversion happen.)









--Rex
On Wed, Sep 28, 2011 at 12:19 AM, Billy <rossrose69 [at] gmail [dot] com> wrote: