RationalLiterals
DRAFT

Misconception:

In Java, a rational fraction, like 1/2 or 120/5, is a literal, a value that is not further evaluated.

Incorrect

Rational fractions are literals

Correct

Rational fractions are divisions of two integer literals

Correction
Here is what's right.

If you previously took a course following HtDP, then you learned that in the Racket-based student languages 1/2 is a literal representing a rational fraction, and a division operation is represented by the function application (/ 1 2).

While this may be true for the Racket student languages, it is not true in Java. Java does not have any type for rational numbers. It only has integer numbers (byte, char, short, int, long) and floating point numbers (float, double). The code 1/2 is an expression, consisting of two int literals, and the division operator. If you evaluate it, you get an integer as a result.

Stay up-to-date

Follow us on  twitter to hear about new misconceptions.