9.3. ��ѧ�����Ͳ�����

PostgreSQL Ϊ��������ṩ����ѧ�������� ������Щ�����п��ܵ�����ж�û��һ�����ѧ��ͳ������ (���磬����/ʱ������)�������������½�������ʵ�ʵ���Ϊ��

Table 9-2 ��ʾ�˿��õ���ѧ��������

Table 9-2. ��ѧ������

�����������������
+ ��2 + 35
- ��2 - 3-1
* ��2 * 36
/ �� �������������ضϽ����4 / 22
% ģ�� �����ࣩ5 % 41
^ �ݣ�ָ�����㣩2.0 ^ 3.08
|/ ƽ����|/ 25.05
||/ ������||/ 27.03
! �׳�5 !120
!! �׳� ��ǰ׺������!! 5120
@ ����ֵ@ -5.05
& ������ AND91 & 1511
| ������ OR32 | 335
# ������ XOR17 # 520
~ ������ NOT~1-2
<< ����������1 << 416
>> ����������8 >> 22

��λ����������ֻ�����������������ͣ��������IJ�������������ȫ����ֵ�������͡� ��λ�����IJ���������������λ������ bit �� bit varying�� �� Table 9-10 ��ʾ��

Table 9-3 ��ʾ�˿��õ���ѧ������ �ڸñ��У�dp ��ʾdouble precision�� ��Щ����������඼�ж��ֲ�ͬ����ʽ�������Dz�����ͬ�� �����ر�ָ�����κ��ض���ʽ�ĺ��������غ����IJ�����ͬ���������͡� ���� double precision ���ݵĺ������������ ����ϵͳ�� C ��Ļ�����ʵ�ֵģ���ˣ�׼ȷ�Ⱥ� ��ֵ��Χ�������Ϊ�Ǹ�������ϵͳ���仯�ġ�

Table 9-3. ��ѧ����

�����������������������
abs(x)����x������ͬ������ֵabs(-17.4)17.4
cbrt(dp)dp������cbrt(27.0)3
ceil(dp ���� numeric)��������ͬ��С�ڲ�������С������ceil(-42.8)-42
ceiling(dp or numeric)����������ͬ����С�ڲ�������С������ceil �ı�����ceiling(-95.3)-95
degrees(dp)dp�ѻ���תΪ�Ƕ�degrees(0.5)28.6478897565412
exp(dp �� numeric)��������ͬ��Ȼָ��exp(1.0)2.71828182845905
floor(dp �� numeric)��������ͬ�����ڲ������������floor(-42.8)-43
ln(dp �� numeric)��������ͬ��Ȼ����ln(2.0)0.693147180559945
log(dp �� numeric)��������ͬ10 Ϊ�׵Ķ���log(100.0)2
log(b numeric, x numeric)numericָ�������Ķ���log(2.0, 64.0)6.0000000000
mod(y, x)(�Ͳ���������ͬ)���� y/x ��������ģ��mod(9,4)1
pi()dp"π" ����pi()3.14159265358979
power(a dp, b dp)dp��a�� b ����power(9.0, 3.0)729
power(a numeric, b numeric)numeric��a�� b ����power(9.0, 3.0)729
radians(dp)dp�ѽǶ�תΪ����radians(45.0)0.785398163397448
random()dp0.0 �� 1.0 ֮��������ֵrandom() 
round(dp ���� numeric)����������ͬ��Բ��Ϊ��ӽ�������round(42.4)42
round(v numeric, s integer)numericԲ��ΪsλС������round(42.4382, 2)42.44
setseed(dp)integer���� random() ������������setseed(0.54823)1177314959
sign(dp ���� numeric)����������ͬ�������ķ��ţ�-1, 0, +1��sign(-8.4)-1
sqrt(dp ���� numeric)����������ͬ��ƽ����sqrt(2.0)1.4142135623731
trunc(dp ���� numeric)����������ͬ���ضϣ����㿿����trunc(42.8)42
trunc(v numeric, s integer)numeric�ض�Ϊ s С��λ�õ�����trunc(42.4382, 2)42.43
width_bucket(op numeric, b1 numeric, b2 numeric, count integer)integer ����һ��Ͱ�����Ͱ����һ���� count ��Ͱ�� �Ͻ�Ϊ b1���½�Ϊ b2 �ĵ�����ͼ�� operand ����������Ǹ�Ͱ�� width_bucket(5.35, 0.024, 10.06, 5)3

���Table 9-4 ��ʾ�˿��õ����Ǻ����� �������Ǻ�����������Ϊ double precision �IJ����ͷ������͡�

Table 9-4. ���Ǻ���

��������
acos(x)������
asin(x)������
atan(x)������
atan2(x, y)���� y/x �ķ�����
cos(x)����
cot(x)����
sin(x)����
tan(x)����