"possible loss of precision" is Java going crazy or I'm missing something?

Posted by Lo'oris on Stack Overflow See other posts from Stack Overflow or by Lo'oris
Published on 2010-05-09T20:36:49Z Indexed on 2010/05/09 20:38 UTC
Read the original article Hit count: 439

Filed under:
|
|

I'm getting a "loss of precision" error when there should be none, AFAIK.

this is an instance variable:

byte move=0;

this happens in a method of this class:

this.move=(this.move<<4)|(byte)(Guy.moven.indexOf("left")&0xF);

move is a byte, move is still a byte, and the rest is being cast to a byte.

I get this error:

[javac] /Users/looris/Sviluppo/dumdedum/client/src/net/looris/android/toutry/Guy.java:245: possible loss of precision
[javac] found   : int
[javac] required: byte
[javac]             this.move=(this.move<<4)|(byte)(Guy.moven.indexOf("left")&0xF);
[javac]                                         ^

I've tried many variations but I still get the same error.

I'm now clueless.

© Stack Overflow or respective owner

Related posts about java

Related posts about precision