Handling numeric data types in built-in functions : Numeric Functions « PL SQL Data Types « Oracle PL/SQL Tutorial






PL/SQL supports the same built-in numeric functions as SQL.

Most numeric functions are accurate to 38 decimal places.

Functions COS, COSH, EXP, LN, LOG, SIN, SINH, SQRT, TAN, and TANH are accurate to 36 decimal digits.

Functions ACOS, ASIN, ATAN, and ATAN2 are accurate to 30 decimal digits.

Most built-in Oracle functions that work with numeric data can be overloaded to work with BINARY_DOUBLE and BINARY_FLOAT datatypes.

But sometimes, you might have to force them to use the appropriate datatypes.

SQL> set timing on
SQL>
SQL> declare
  2      v_nr number;
  3  begin
  4      for i in 1..1000000 loop
  5          v_nr:=sqrt(i);
  6      end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:01.62
SQL>
SQL> declare
  2      v_nr binary_float;
  3  begin
  4      for i in 1..1000000 loop
  5          v_nr:=sqrt(i);
  6      end loop;
  7  end;
  8  /

PL/SQL procedure successfully completed.

Elapsed: 00:00:08.53
SQL>
SQL> set timing off








21.18.Numeric Functions
21.18.1.Handling numeric data types in built-in functions