I have this code in C#
byte[] t = {6, 250, 215}.
But in Java is
byte[] t = {6, -6, -41}.
How to solve this problem?
How to solve this problem
the 1st is read about how java represents data types..:
byte: The byte data type is an 8-bit signed two's complement integer. It has a minimum value of -128 and a maximum value of 127 (inclusive). The byte data type can be useful for saving memory in large arrays, where the memory savings actually matters. They can also be used in place of int where their limits help to clarify your code; the fact that a variable's range is limited can serve as a form of documentation.
as @bradimus statements, java's byte is an 8-bits 2 complement signed int but in C# you will never see a negative byte value
if you consider to make a conversion...
-6 in java can be 256+(-6) = 250 in C#
and carefully consider the max and min in a java-byte if you need to convert from C# to java....
byteand javabyteare not equivalent. Java'sbytes are signed.{ 0b00000110, 0b11111010, 0b1101011 }. They have different interpretations.