Sunday, May 9, 2010

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

Programmer Question


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.





Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails