Short Data Type using JAVA
on May 30, 2018
Short Data Type using JAVA
short is a signed 16-bit type. It has a range from –32,768 to 32,767. It is probably the
least-used Java type, since it is defined as having its high byte first (called big-endian
format). This type is mostly applicable to 16-bit computers, which are becoming
increasingly scarce.
Here are some examples of short variable declarations:
short s;
short t;
“Endianness” describes how multibyte data types, such as short, int, and long, are
stored in memory. If it takes 2 bytes to represent a short, then which one comes first, the
most significant or the least significant? To say that a machine is big-endian, means that
the most significant byte is first, followed by the least significant one. Machines such as
the SPARC and PowerPC are big-endian, while the Intel x86 series is little-endian.
0 comments: