Oracle PL/SQL - What is the output: Parentheses vs operator precedence?

Question

What is the output of the following code?

DECLARE 
  salary      NUMBER := 60000; 
  commission  NUMBER := 0.10; 
BEGIN 

DBMS_OUTPUT.PUT_LINE('8 + 6 / 2 = ' || TO_CHAR(8 + 6 / 2)); 
DBMS_OUTPUT.PUT_LINE('(8 + 6) / 2 = ' || TO_CHAR((8 + 6) / 2)); 
END; 
/ 

Note

Parentheses override default operator precedence:

Demo

SQL>
SQL> DECLARE--  w ww.  java  2  s .c o  m
  2    salary      NUMBER := 60000;
  3    commission  NUMBER := 0.10;
  4  BEGIN
  5
  6  DBMS_OUTPUT.PUT_LINE('8 + 6 / 2 = ' || TO_CHAR(8 + 6 / 2));
  7  DBMS_OUTPUT.PUT_LINE('(8 + 6) / 2 = ' || TO_CHAR((8 + 6) / 2));
  8  END;
  9  /
8 + 6 / 2 = 11
(8 + 6) / 2 = 7

PL/SQL procedure successfully completed.

SQL>

Related Quiz