小智 13
由于Int()似乎像Floor()一样工作,你可以得到这样的Ceiling:-Int(-x)
此答案使用VBA for Access,源自http://www.tek-tips.com/faqs.cfm?fid=5031:
Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
' X is the value you want to round
' Factor is the optional multiple to which you want to round, defaulting to 1
Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function
Run Code Online (Sandbox Code Playgroud)
请注意,对于负X,此答案在数学上是正确的.有关背景信息,请参阅http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Spreadsheet_software.
| 归档时间: |
|
| 查看次数: |
10345 次 |
| 最近记录: |