返回舍入到指定精度的源。Returns the rounded source to the specified precision.


round(source [, Precision])round(source [, Precision])


  • source:计算舍入时基于的源标量。source: The source scalar the round is calculated on.
  • 精度:源将舍入到的位数(默认值为 0)。Precision: Number of digits the source will be rounded to.(default value is 0)


舍入到指定精度的源。The rounded source to the specified precision.

Round 与 bin()/floor() 的不同之处在于,前者将数字舍入到特定的位数,后者将值舍入到给定 bin 大小的整数倍(round(2.15, 1) 返回 2.2,而 bin(2.15, 1) 则返回 2)。Round is different than bin()/floor() in that the first rounds a number to a specific number of digits while the last rounds value to an integer multiple of a given bin size (round(2.15, 1) returns 2.2 while bin(2.15, 1) returns 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