Name

sqrt, cbrt — square and cube root functions

Synopsis

sqrt( in x double precision);
 
cbrt( in x double precision);
 

Description

These functions work with double precision floating point numbers. They convert their argument to an IEEE 64-bit float and return a result of that type.

:  sqrt	square root of x.
:  cbrt	cube root of x; unlike sqrt, accepts negative values.
    

Parameters

x

double precision

Return Values

sqrt returns a IEEE 64-bit float.

Examples

Example 24.426. Stored Procedure Example

Calculate square roots of integers between 2 numbers.

SQL> create procedure
calc_sqrts (in _from integer, in _to integer)
{
  declare i integer;
  declare result double precision;

  result_names (i, result);

  i := _from;
  while (i < _to)
   {
     result (i, sqrt (i));
     i := i + 1;
   }
}
;
(0) (0) (1) (1) (1) (1) (1) (1) (1) (1) (2) (2) (2) (1)
Done. -- 7 msec.
SQL> calc_sqrts(1, 10);
i                 result
INTEGER NOT NULL  DOUBLE PRECISION NOT NULL
_______________________________________________________________________________

1                                  1.000000
2                                  1.414214
3                                  1.732051
4                                  2.000000
5                                  2.236068
6                                  2.449490
7                                  2.645751
8                                  2.828427
9                                  3.000000

9 Rows. -- 3 msec.
      

See Also

exp, sqrt, log10, power


© 1992 - OpenLink Software. All rights reserved.

Making Technology Work for You®