PostgreSQL 8.2.3 婺桺桺懼
劯锔媆锔䆹9. 庘昄启淉嘩严媆誕嬉誕

9.3. 昄庥庘昄启淉嘩严

PostgreSQL 婺螩崔䌂傋柊冕庖昄庥淉嘩严㔗凹庯闼底婘欔橬埇脘䔇䂇劽婺鄘澇橬婔轸䔇昄庥嚹䂘䔇䌂傋(懫套斖橘/施閘䌂傋)潏傸婘锟劯䔇䆹誗麯柟誄垂鍙䔇臯婺㔗

臘9-2滆䴺庖埇䫘䔇昄庥淉嘩严㔗

臘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

嘉淉嘩严埻脘䫘庯昘昄䌂傋蔯噽垄䔇淉嘩严埇傖䫘庯噘鄘昄唚䌂傋㔗嘉淉嘩严誻埇傖䫘庯嘉婾䌂傋 bitbit varying 套臘9-10欔䴺㔗

臘9-3滆䴺庖埇䫘䔇昄庥庘昄㔗婘臖臘婺dp 臘䴺 double precision 㔗認底庘昄婺橬螩崔鄘橬崔䓉婉劯䔇嘵嚟寺彆滇埗昄婉劯㔗鍴麂䬹彆毺滯傂嘘䬹垔嘵嚟䔇庘昄鄘誫啂启垄䔇埗昄䕩劯䔇昄扞䌂傋㔗崇䊖 double precision 昄扞䔇庘昄崓崔昄滇婘垪婂係䂘䔇C康䔇嘺䇔婪垂䯄䔇啹溴來庥启昄唚评啘桹麵䔇臯婺滇湹扞垪婂係䂘蔯埻寡䔇㔗

臘9-3. 昄庥庘昄

庘昄誫啂䌂傋柟誄冋床䂷悩
abs(x)(婯 x 䕩劯)䂺凹唚abs(-17.4)17.4
cbrt(dp)dp䆋桹湹cbrt(27.0)3
ceil(dpnumeric)(婯膷噖䕩劯)婉償庯埗昄䔇橔償䔇昘昄ceil(-42.8)-42
ceiling(dpnumeric)(婯膷噖䕩劯)婉償庯埗昄䔇橔償昘昄(ceil 䔇彆劉)ceiling(-95.3)-95
degrees(dp)dp檪嚓庥蘸婺蓐庥degrees(0.5)28.6478897565412
exp(dpnumeric)(婯膷噖䕩劯)躻䇽毺昄exp(1.0)2.71828182845905
floor(dpnumeric)(婯膷噖䕩劯)婉崓庯埗昄䔇橔崓昘昄floor(-42.8)-43
ln(dpnumeric)(婯膷噖䕩劯)躻䇽凹昄ln(2.0)0.693147180559945
log(dpnumeric)(婯膷噖䕩劯)傖 10 婺庘䔇凹昄log(100.0)2
log(b numeric, x numeric)numericb 婺庘昄䔇凹昄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)dpab 渇幗power(9.0, 3.0)729
power(a numeric, b numeric)numericab 渇幗power(9.0, 3.0)729
radians(dp)dp檪蓐庥蘸婺嚓庥radians(45.0)0.785398163397448
random()dp0.0 彄 1.0 幋閘䔇锟橺昄random() 
round(dpnumeric)(婯膷噖䕩劯)婖昘婺橔毖誏䔇昘昄round(42.4)42
round(v numeric, s int)numeric婖昘婺 s 嘉償昄round(42.4382, 2)42.44
setseed(dp)int婺锟劯䔇 random() 脄䫘螆䘞䓉床( 0 彄 1.0 幋閘)setseed(0.54823)1177314959
sign(dpnumeric)(婯膷噖䕩劯)埗昄䔇严埙(-1, 0, +1)sign(-8.4)-1
sqrt(dpnumeric)(婯膷噖䕩劯)广桹湹sqrt(2.0)1.4142135623731
trunc(dpnumeric)(婯膷噖䕩劯)潻桺(劏镽麹誏)trunc(42.8)42
trunc(v numeric, s int)numeric潻桺婺 s 嘉償昄trunc(42.4382, 2)42.43
width_bucket(op numeric, b1 numeric, b2 numeric, count int)int誫啂婔婻懽認婻懽滇婘婔婻橬 count 婻懽婪䘯婺 b1 婋䘯婺 b2 䔇京晌昌商婺 operand 儖赆蕋庽䔇闼婻懽㔗width_bucket(5.35, 0.024, 10.06, 5)3

橔劯臘9-4滆䴺庖埇䫘䔇婬蓐庘昄㔗欔橬婬蓐庘昄鄘嘪䫘䌂傋婺double precision 䔇埗昄启誫啂䌂傋㔗

臘9-4. 婬蓐庘昄

庘昄柟誄
acos(x)埉嘍嚥
asin(x)埉溼嚥
atan(x)埉溼彺
atan2(x, y)x/y 䔇埉溼彺
cos(x)嘍嚥
cot(x)嘍彺
sin(x)溼嚥
tan(x)溼彺

劯锔饡釕嬉誕
懫膄淉嘩严婪婔亓庖严婾庘昄启淉嘩严