9.0 / 5.0 * 100 + 32(return to questions)
3.5999999999999996Java does not represent numbers in base 10, but instead it represents the numbers in base 2. This does not cause a problem with integers, but it does with floating point numbers. The fractional part of the number is approximated to the closest base 2 floating point number available to Java. The error is usually quite small, but the errors will accumulate when performing operations such as addition. As a result, you can get different answers to mathematically equivalent expressions. Try 1.3 + 1.3 + 1. Lesson: "equality" of floating-point calculations probably means "equal up to some tolerance." The difference between the true value and the one calculated by Java is less than . (return to questions)
Note that in Java you must give a variable a value before you can use it. The DrJava interactions pane is forgiving of this error because it always gives a variable an initial value of 0. However, you need to remember that in Java, you must declare a variable and assign a value to it before you can use it. Don't worry if you forget, a Java error message will remind you! (return to questions)
c = (char) (d + 1)There are about 65,000 characters, and not all of them can be displayed in all windows, so you may get some strange results doing arithmetic on char. (return to questions)