GitHub GitHub: 線上編輯

ROUND()

傳回四捨五入後的來源至指定的精準度。

語法

round(source [, Precision])

引數

  • source: 計算圓形的來源純量。
  • 精準度: 來源將四捨五入至的位數 (預設值為 0)。

退貨

將來源四捨五入至指定的精準度。

捨入不同於 bin()/floor() ,因為第一次將數字捨入為特定位數,而最後一次將值捨入為給定 bin 大小之整數倍數 (round (2.15, 1) 傳回 2.2 , bin (2.15, 1) 傳回 2)。

範例

round(2.15, 1)                   // 2.2
round(2.15) (which is the same as round(2.15, 0))                   // 2
round(-50.55, -2)                   // -100
round(21.5, -1)                   // 20