Angela Jessi

Ranch Hand

Posts: 428

posted 15 years ago

Signed numbers use the leftmost bit to represent the sign and the remaining bits to represent the magnitude. Unsigned numbers use all the bits to represent the magnitude of the number.

long and short just indicate the size (number of bits) of the bit pattern used to represent a number. long has more bits (64)while short has fewer bits (16).

Java primitive integral data types are all signed with the exception of char (for which a sign has no meaning anyway).

[This message has been edited by JUNILU LACAR (edited June 22, 2001).]

long and short just indicate the size (number of bits) of the bit pattern used to represent a number. long has more bits (64)while short has fewer bits (16).

Java primitive integral data types are all signed with the exception of char (for which a sign has no meaning anyway).

[This message has been edited by JUNILU LACAR (edited June 22, 2001).]

*Practice only makes habit, only perfect practice makes perfect.
So, practice mindfully. Practice doing the right things and doing things right. *— Junilu

[How to Ask Questions] [How to Answer Questions]

Angela Jessi

Ranch Hand

Posts: 428

posted 15 years ago

Can you please give me one example please?

Thanks

Angela

Thanks

Angela

Originally posted by JUNILU LACAR:

Signed numbers use the leftmost bit to represent the sign and the remaining bits to represent the magnitude. Unsigned numbers use all the bits to represent the magnitude of the number.

long and short just indicate the size (number of bits) of the bit pattern used to represent a number. long has more bits (64)while short has fewer bits (16).

Java primitive integral data types are all signed with the exception of char (for which a sign has no meaning anyway).

[This message has been edited by JUNILU LACAR (edited June 22, 2001).]

posted 15 years ago

See the campfire story http://www.javaranch.com/campfire/StoryBits.jsp

Angela, the Internet is chock-full of articles that I'm sure could explain the basics of bits and bytes better than anyone could in a single post. Bring up your favorite search engine--mine is http://www.google.com --and type in "bits and bytes" and you should come up with more than enough information. Google has a link to just the article you need in the very first page it lists. Sorry if this seems curt but I think that sometimes folks just have to learn how to help themselves.

Best regards,

Junilu

Angela, the Internet is chock-full of articles that I'm sure could explain the basics of bits and bytes better than anyone could in a single post. Bring up your favorite search engine--mine is http://www.google.com --and type in "bits and bytes" and you should come up with more than enough information. Google has a link to just the article you need in the very first page it lists. Sorry if this seems curt but I think that sometimes folks just have to learn how to help themselves.

Best regards,

Junilu

*Practice only makes habit, only perfect practice makes perfect.
So, practice mindfully. Practice doing the right things and doing things right. *— Junilu

[How to Ask Questions] [How to Answer Questions]

Bob Graffagnino

Ranch Hand

Posts: 81

Mikael Jonasson

Ranch Hand

Posts: 158

posted 15 years ago

The difference between a signed and an unsigned version of a variable is wether they allow negatives or not.

a signed byte for instans has the range between -128 and 127, while the unsigned version of it has the range between 0 and 255.

Making a variable unsigned means that the entire variable (all it's bits) are used for positive values.

ok?

/Mike

a signed byte for instans has the range between -128 and 127, while the unsigned version of it has the range between 0 and 255.

Making a variable unsigned means that the entire variable (all it's bits) are used for positive values.

ok?

/Mike