The Java floating-point types have special values for negative zero, positive and negative infinity, and not-a-number, or NaN. I hacked up a short program (below) to print out a multiplication table for these special values, and also tables for the +, -, /, and % operators as well. For the most part, these special values behave as you'd expect when you do arithmetic with them. But some of the values produce results that may seem suprising. 1/0 produces infinity, of course, but 0/0 produces NaN which may not be obvious at first. (If you divide by zero using an integer type instead of a floating point type, you get an ArithmeticException. Floating-point arithmetic never throws exceptions in Java.)
The code is below. Cut, paste, compile and run..



