sign « byte « Java Data Type Q&A





1. What is the best way to work around the fact that ALL Java bytes are signed?    stackoverflow.com

In Java, there is no such thing as an unsigned byte. Working with some low level code, occasionally you need to work with bytes that have unsigned values greater than 128, which ...

2. James Gosling's explanation of why Java's byte is signed    stackoverflow.com

I was initially surprised that Java decides to specify that byte is signed, with a range from -128..127 (inclusive). I'm under the impression that most 8-bit number representations are unsigned, with ...

3. Understanding Java unsigned numbers    stackoverflow.com

I want to understand how to convert signed number into unsigned. lets say I have this:

byte number = 127; // '1111111'
In order to make it unsigned I have to choose "bigger" data ...

4. Behaviour of unsigned right shift applied to byte variable    stackoverflow.com

Consider the following snip of java code

byte b=(byte) 0xf1;
byte c=(byte)(b>>4);
byte d=(byte) (b>>>4);
output:
c=0xff
expected output:
c=0x0f
how? as b in binary 1111 0001 after unsigned right shift 0000 1111 hence 0x0f but why is it 0xff ...

5. can we make unsigned byte in java    stackoverflow.com

i am trying to convert a signed byte in unsigned , the problem is the data I am receiving is Unsigned and Java does not support unsigned byte so when it ...

6. java invoice print CommPortIdentifier with unsigned bytes issue    stackoverflow.com

Hey, I need to print invoices in a thermal invoice printer I wrote this program to do just that (see below) However, for localization reasons I need send to the printer characters with ...

7. Unsigned Bytes in Java    stackoverflow.com

Bytes in Java are signed by default. I see on other posts that a workaround to have unsigned bytes is something similar to that: int num = (int) bite & 0xFF Could ...

8. Need help to output unsigned byte > 127    coderanch.com

I can't seem to do this, as you can see in my code. It's supposed to output a value of 0x90 but it outputs a value of 0x5B when I look at the results of my output in a binary/hex dump. import java.io.*; public class ReadData { public static void main(String[]args) throws IOException { new ReadData().doIt(); } void doIt() throws IOException ...

9. change java byte to unsigned    coderanch.com

Well, there aren't any unsigned types in Java, so what do you mean? When you assign an integral type to a larger integral type, Java will sign-extend it. If you then zero-out the higher-order bits, then you have an integer with the value that would have been represented by the smaller type, if it were unsigned. Example: byte b = (byte) ...





10. Workaround for signed bytes?    forums.oracle.com

There is no need to convert the nibbles to bytes since they are promotedback to ints when use as indexes into the 2d array. Assuming 'b' is a byte then all you need is int col = b & 0x0f;//low, right nybble int row = (b & 0xf0 )>>>4; //shift high bits over.

11. unsigned byte    forums.oracle.com

12. how to express the unsigned byte in Java?    forums.oracle.com

The value of a byte is from 0 to 255 - or binary 00000000 to 11111111. When Java uses a byte it treats 1 to 127 as positive, and 128 to 255 are expressed as negative, using two's complement arithmetic. The byte that Java expresses as -1 is binary 11111111, or 255. To express byte values as 0 to 255, cast ...

13. A few questions about signed bytes.    forums.oracle.com

Hi, ive been programming in java for awhile, and it is my first language so i havnt come from a language where i would have used signed/unsigned bytes before. The application im creating requires manipulation and storage of an unsigned byte array input from an rgb camera. Ive googled a fair bit, but havnt found any of the information i think ...

14. unsigned byte String representation    forums.oracle.com

Okay, let's go back about three steps. You are sending these characters with ogoneks from your ActiveX to a servlet (as you said) via an HTTP request? (You used the word "calling" which is confusing and ambiguous.) If so, a GET or POST request? And when you send the characters, what do you see in the servlet? What bytes, I mean? ...