Friday, May 31, 2013

error: possible loss of precision required: byte found: int

error: possible loss of precision required
required: byte found: int

This error can be overcome by doing a simple typecast as follows:

byte a,b,c;
c= (byte) (a+b); ----> This is because addition of 'byte' data type returns integer.
                                    So a typecast is a must

Very importantly include ( ) around a+b or any other calculation that you do.

No comments:

Post a Comment