O'Reilly logo

Java™ Number Cruncher: The Java Programmer's Guide to Numerical Computing by Ronald Mak

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 2. How Wholesome Are the Integers?

Compared with what we saw of the floating-point types in Chapter 1, the integer types must seem pretty tame and safe! We'll see how valid that assumption is in this chapter.

Java has five integer types named by the keywords byte, short, char, int, and long. The values of these types represent the whole numbers of pure mathematics, which we use for counting and for doing arithmetic that doesn't involve fractions. We must use the word represent because Java's integers, unlike the whole numbers, are not infinite.

The Integer Types and Operations

Table 2-1 shows the bit size, the minimum value, and the maximum value of each of Java's integer types.

Except for type char, which does not have negative values, the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required