Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Java Primitive data types question.?

Hi there I need some help with a particular definition in java that is related to primitive data types. In many descriptions like the byte, int , long and short data types it is described in, for example, the byte stores whole number values in 8-bit signed locations from -128 to +127. I need to know what exactly are bit signed locations.

Thank You for the help

God Bless

2 Answers

Relevance
  • 9 years ago
    Favorite Answer

    The words are in the wrong order. The byte is a location containing 8 bits, and you decide (in the declaration of the variable) whether you are going to interpret it as signed or unsigned. If it is signed, then 1 of these bits stores the sign, the 7 others store the value. In this way you can store a value between -128 and +127 in a byte. If the choice is unsigned, then all the bits are used for the value, and the range is 0 to +255.

  • 9 years ago

    Consider a possible four bit numbers 0000, 0001, 0010.....1110, 1111 (Decimal equivalents are 0-15). Here, we did not talk about sign at al. In fact numbers can be negative also. To take care of sign, 1 bit is left for sign. Usually left most bit is taken as sign. If that bit is 0 then the number can be considered as positive else nagative. Thus, the four bit sequence 0000, 0001, ...0111,1000,1010,.....1110, 1111 are in decimal systems as 7,6,...0,-0,-1,....-6, -7.

    The same is applicable for any bit numbers

Still have questions? Get your answers by asking now.