• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Unsigned Variables

 
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to know what is unsigned int & unsigned long?
Also what long variable and short variable
Thanks
Angela
 
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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).]
 
Angela Jessi
Ranch Hand
Posts: 428
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can you please give me one example please?
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).]


 
Junilu Lacar
Sheriff
Posts: 17644
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 81
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
short i = 10;
long j = 10;
They both represent numbers. The difference is the amount of space they take up in memory. Consider the binary form of these numbers:
i = 00000000 00001010 (16 bits)
j = 00000000 00000000 00000000 00001010 (64 bits)
 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic