9.3. Mathematical Functions and Operators

9.3. Mathematical Functions and Operators
9.3.數學函數和運算符
Mathematical operators are provided for many PostgreSQL types. For types without standard mathematical conventions (e.g., date/time types) we describe the actual behavior in subsequent sections.
PostgreSQL提供了許多類型的數學運算符。對於沒有標準數學約定的類型(例如,日期/時間類型),我們將在後續部分中描述其實際行爲。
 
Table 9.4 shows the available mathematical operators.
表9.4列出了可用的數學運算符。
 
uploading.4e448015.gif轉存失敗重新上傳取消
uploading.4e448015.gif轉存失敗重新上傳取消
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 bit and bit varying,as shown in Table 9.13.
按位運算符僅適用於整數數據類型,而其他運算符可用於所有數字數據類型。 如表9.13所示,按位運算符還可用於位串類型bit和bit variant。
 
Table 9.5 shows the available mathematical functions. In the table, dp indicates double precisionMany 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 double precision 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.
 
表9.5列出了可用的數學函數。 在表中,dp表示雙精度。 這些函數中的許多函數都以不同的參數類型的多種形式提供。 除非另有說明,任何給定形式的函數都將返回與其參數相同的數據類型。 使用雙精度數據的函數主要在主機系統的C庫實現; 因此,邊界情況下的準確性和行爲可能會因主機系統而異。
 
uploading.4e448015.gif轉存失敗重新上傳取消
uploading.4e448015.gif轉存失敗重新上傳取消
uploading.4e448015.gif轉存失敗重新上傳取消
uploading.4e448015.gif轉存失敗重新上傳取消
Table 9.6 shows functions for generating random numbers.
表9.6展示了可以生成隨機數的函數。
 
uploading.4e448015.gif轉存失敗重新上傳取消
The characteristics of the values returned by random() depend on the system implementation. It is not suitable for cryptographic applications; see pgcrypto module for an alternative.
random()返回的值的特徵取決於系統實現。 它不適用於密碼應用程序;密碼應用程序可參見pgcrypto模塊。
 
Finally, Table 9.7 shows the available trigonometric functions. All trigonometric functions take arguments and return values of type double precision. Each of the trigonometric functions comes in two variants, one that measures angles in radians and one that measures angles in degrees.
最後,表9.7顯示了可用的三角函數。 所有三角函數均接受參數並返回雙精度類型的值。 每個三角函數都有兩種變體,一種以弧度爲單位,另一種以度爲單位。
 
uploading.4e448015.gif轉存失敗重新上傳取消
Note
Another way to work with angles measured in degrees is to use the unit transformation functions radians() and degrees() shown earlier. However, using the degree-based trigonometric functions is preferred, as that way avoids round-off error for special cases such as sind(30).
處理以度爲單位的角度的另一種方法是使用前面提到的單位轉換函數radians()和degree()。 但是,最好使用基於度的三角函數,因爲這樣可以避免在諸如sind(30)之類的特殊情況下產生舍入誤差。
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章