Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Info
titleExample - Operator precedence


Code Block
consume {
    boolean a = false;
    boolean b = false;
    boolean c = true;
    boolean x;
    // The following statement will be parsed as 
	// false && (false || true)
    // and evaluate to false
    x = a && b || c;
    debug(x);
    // This will evaluate to true
    x = (a && b) || c;
    debug(x);
}



Note
titleJava and APL may differ

In some circumstances,  APL and Java are handling numeric values differently.  APL may be automatically expanded to avoid overflow, this applies also to constant expressions.

Example 1: A statement like: long x=1000000000000; is ok in APL, but will not compile in Java.

Example 2: An expression like: long x=1000000*1000000; This works as expected in APL, but in Java would assign to x the value -727379968 due to overflow.