Java Reference
In-Depth Information
Chapter 5. Numbers
Introduction
Numbers are basic to just about any computation. They're used for array indices, temperat-
ures, salaries, ratings, and an infinite variety of things. Yet they're not as simple as they
seem. With floating-point numbers, how accurate is accurate? With random numbers, how
random is random? With strings that should contain a number, what actually constitutes a
number?
Java has several built-in or “primitive” types that can be used to represent numbers, summar-
ized in Table 5-1 with their “wrapper” (object) types, as well as some numeric types that do
not represent primitive types. Note that unlike languages such as C or Perl, which don't spe-
cify the size or precision of numeric types, Java—with its goal of portability—specifies these
exactly and states that they are the same on all platforms.
Search WWH ::




Custom Search