Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: fixed first compliant solution to comply with NUM18-J as well.

...

Code Block
bgColor#ccccff
strictfp class Example {
  public static void main(String[] args) {
    double d = Double.MAX_VALUE;
    System.out.println("This value \"" + ((d * 1.11d) / 1.11d) + "\" cannot be represented as double.");
  }
}

Note that this compliant solution also specifies that the floating point literals are of type double to clarify their expected type; this complies with guideline NUM18-J. Be aware of numeric promotion behavior.

Noncompliant Code Example

...