Java Reference
In-Depth Information
Example 3.1 Coercing a byte to int as if the byte were unsigned
byte c;
int ival;
...
ival = ((int) c) && 0xFF; // explicit cast needed
3.2.1.2
Java provides two different precisions of floating point numbers. They are:
Floating Point Types
float : 32 bits
double : 64 bits
The float type is not very useful at that precision, so double is much
more commonly seen. For other situations where precision is important, but
you can spare some cycles, consider the BigDecimal and BigInteger
object classes.
Java floating point numbers are specified to follow the IEEE floating point
standard, IEEE 754.
3.2.1.3
Java also has a boolean type, along with constants true and false . In Java,
unlike C/C++, boolean values are a distinct type, and do not convert to
numeric types. For example, it is common in C to write:
Other Types
if (strlen(instr)) {
strcpy(buffer, instr);
}
In this case, the integer result of strlen() is used as a boolean , where 0 is
false and any other value is true . This doesn't work in Java. The expression
must be of a boolean type.
Java also has a char type, which is not the same as a byte . The char is a
character, and in Java, characters are represented using Unicode (UTF-16).
They take two bytes each.
For more discussion on the differences between byte s and char s and
about Unicode, read the Java tutorial on the java.sun.com Web site or visit
www.unicode.org , the international standard's Web site.
Search WWH ::




Custom Search