Oracle PL/SQL Tutorial/PL SQL Data Types/Numeric Functions

Материал из SQL эксперт
Перейти к: навигация, поиск

Handling numeric data types in built-in functions

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.



   <source lang="sql">

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</source>