mysql數學函數之truncate用法

語法
TRUNCATE(X,D)

Returns the number X, truncated to D decimal places. If D is 0, the result has no decimal point or fractional part. D can be negative to cause D digits left of the decimal point of the value X to become zero. 
返回數字X,截斷到D小數位。 如果D爲0,結果沒有小數點或小數部分。 D是負數,導致值X的小數點左邊的D數字變爲零。
————————————————
 

 

 

 

SELECT truncate(1314.1314, 3);          # 1314.131
SELECT truncate(1314.1314, 1);          # 1314.1
SELECT truncate(1314.1314, 0);          # 1314
SELECT truncate(1314.1314, -1);         # 1310
SELECT truncate(1314.1314, -3);         # 1000
SELECT truncate(-1314.1314, -1);        # -1310
SELECT truncate(-1314.1314, -3);        # -1000
SELECT truncate(1314.1314*100, -3);     # 131000
1
————————————————
版權聲明:本文爲CSDN博主「劉鴻亮」的原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處鏈接及本聲明。
原文鏈接:https://blog.csdn.net/csdn_0_001/article/details/79480699

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章