Answer the question
In order to leave comments, you need to log in
Negative Byte?
Good morning!
There is a Java code like this
public static boolean GMSetGameAttriByte(byte type, byte value) throws Exception {
OctetsStream os = new OctetsStream();
os.marshal(value);
return DeliveryDB.GMSetGameAttri(-1, type, (Octets)os);
}
public static byte GMGetDoubleExp() throws Exception {
return DeliveryDB.GMGetGameAttriByte(-52);
}
Answer the question
In order to leave comments, you need to log in
Firstly, you need a different GMGetGameAttriByte function, with 1 argument, and you have 2, and secondly, what kind of code is this in general?
what's the mess in your head?
a byte is 8 bits. it is neither negative nor positive. these are eight bits, each of which can be either set or reset.
next level.
number encoding. integer (signed/unsigned), fixed point, floating point. you google it yourself.
here's a starter for you: signed integers - the most significant bit is reserved for the sign, from which the number of bits encoding the number decreases, (in the same bytes, unsigned 0-256, signed -127 +128 but a sign appears)
10000001 = this is 129 or minus one.
If you have a server written in one language (Java), and a client in another (C#), byte types do not run between them, they send data to each other. Types are just descriptive structures of a programming language and have nothing to do with data. It's just easier for a programmer to get the value of byte myVar = 129 instead of 10000001.
byte in Java min value = -128, max value = 127.
byte in C# min value = 0, max value = 255
sbyte in C# min value = -128, max value = 127
My opinion is that you are simply entangled in three pines.
Another very important difference between Java and .Net is in byte order . .Net defaults to Little Endian, Java defaults to Big Endian. This information is not specific to your question, but it may be useful in the future.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question